fix(ssa): use abi.PathOf() for correct package path in interface metadata
Fixes os.ReadDir segfault caused by package path mismatch between llgo overlay packages and canonical standard library paths. The issue occurred in: os.ReadDir → sort.Slice → reflectlite.Swapper where internal/reflectlite.Type interface has private methods common() and uncommon(). Using mPkg.Path() returned the overlay path 'github.com/goplus/llgo/runtime/internal/lib/internal/reflectlite' instead of the canonical 'internal/reflectlite', causing runtime to only fill public methods and leave private method pointers NULL. Changed to use abi.PathOf() which returns the correct canonical package path for matching, ensuring all interface methods (both public and private) are properly filled in the interface table. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,19 +7,12 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create an identifier node
|
||||
ident := &ast.Ident{
|
||||
NamePos: token.Pos(1),
|
||||
Name: "foo",
|
||||
}
|
||||
|
||||
// Convert to ast.Expr interface
|
||||
// The ast.Expr interface has a private method exprNode()
|
||||
// Before the fix, this interface conversion would cause segfaults
|
||||
// when calling methods because the PkgPath was incorrectly set
|
||||
var expr ast.Expr = ident
|
||||
|
||||
// Call methods on the interface
|
||||
fmt.Printf("Identifier: %s\n", ident.Name)
|
||||
fmt.Printf("Position: %d\n", expr.Pos())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user