diff --git a/compiler/cl/compile.go b/compiler/cl/compile.go index 245e704c..67dbdaf2 100644 --- a/compiler/cl/compile.go +++ b/compiler/cl/compile.go @@ -318,7 +318,9 @@ func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function) (llssa.Fun func (p *context) getFuncBodyPos(f *ssa.Function) token.Position { if f.Object() != nil { - return p.goProg.Fset.Position(f.Object().(*types.Func).Scope().Pos()) + if fn, ok := f.Object().(*types.Func); ok && fn.Scope() != nil { + return p.goProg.Fset.Position(fn.Scope().Pos()) + } } return p.goProg.Fset.Position(f.Pos()) } @@ -760,6 +762,9 @@ func (p *context) getDebugLocScope(v *ssa.Function, pos token.Pos) *types.Scope return nil } funcScope := v.Object().(*types.Func).Scope() + if funcScope == nil { + return nil + } return funcScope.Innermost(pos) }