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