ssa: show detail message of runtime failed

This commit is contained in:
Li Jie
2025-01-09 19:50:01 +08:00
parent 4126992a8f
commit 4ff4ceeb22

View File

@@ -17,6 +17,7 @@
package ssa package ssa
import ( import (
"fmt"
"go/token" "go/token"
"go/types" "go/types"
"runtime" "runtime"
@@ -280,16 +281,23 @@ func (p Program) runtime() *types.Package {
} }
func (p Program) rtNamed(name string) *types.Named { func (p Program) rtNamed(name string) *types.Named {
t := p.runtime().Scope().Lookup(name).Type() if rt := p.runtime(); rt != nil {
for { if rtScope := rt.Scope(); rtScope != nil {
if alias, ok := t.(*types.Alias); ok { if obj := rtScope.Lookup(name); obj != nil {
t = types.Unalias(alias) t := obj.Type()
} else { for {
break if alias, ok := t.(*types.Alias); ok {
t = types.Unalias(alias)
} else {
break
}
}
t, _ = p.gocvt.cvtNamed(t.(*types.Named))
return t.(*types.Named)
}
} }
} }
tyNamed, _ := p.gocvt.cvtNamed(t.(*types.Named)) panic(fmt.Errorf("runtime type (%s) not found, install from pre-built package or set LLGO_ROOT", name))
return tyNamed
} }
func (p Program) rtType(name string) Type { func (p Program) rtType(name string) Type {