From 164c3e0e7b3650c60610c3fbefbb5fda56ce1c31 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Sun, 19 Jan 2025 19:02:31 +0800 Subject: [PATCH] cl: fix null pointer in processing debug location --- compiler/cl/compile.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) }