From 330cb22351ef422b69c892990f25ea36ede3e8fc Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 3 May 2024 18:35:14 +0800 Subject: [PATCH] TestErrCompileInstrOrValue --- cl/builtin_test.go | 12 ++++++++++++ cl/compile.go | 13 +++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cl/builtin_test.go b/cl/builtin_test.go index da94ef47..4eb7ded8 100644 --- a/cl/builtin_test.go +++ b/cl/builtin_test.go @@ -25,6 +25,18 @@ import ( "golang.org/x/tools/go/ssa" ) +func TestErrCompileInstrOrValue(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Fatal("compileInstrOrValue: no error?") + } + }() + ctx := &context{ + bvals: make(map[ssa.Value]llssa.Expr), + } + ctx.compileInstrOrValue(nil, &ssa.Call{}, true) +} + func TestErrAdvance(t *testing.T) { defer func() { if r := recover(); r == nil { diff --git a/cl/compile.go b/cl/compile.go index e9f7bbd3..06e077fc 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -587,14 +587,11 @@ func (p *context) compileValue(b llssa.Builder, v ssa.Value) llssa.Expr { } } case *ssa.Function: - panic("unreachable") - /* - fn, ftype := p.funcOf(v) - if ftype >= llgoInstrBase { - panic("can't use llgo instruction as a value") - } - return fn.Expr - */ + fn, ftype := p.funcOf(v) + if ftype >= llgoInstrBase { + panic("can't use llgo instruction as a value") + } + return fn.Expr case *ssa.Global: g := p.varOf(v) return g.Expr