Closed aofei closed 1 month ago
$ pwd /Users/aofei/playground/test $ tree . . ├── go.mod ├── go.sum └── hello.go 1 directory, 3 files $ cat hello.go package main import "github.com/goplus/llgo/c" func main() { c.Printf(c.Str("Hello world\n")) }
```sh $ llgo run . panic: interface conversion: types.Object is nil, not *types.Func goroutine 1 [running]: github.com/goplus/llgo/ssa.(*aPackage).rtFunc(0x14005bf2d80, {0x104a279c3, 0xe}) /Users/aofei/workspace/goplus/llgo/ssa/package.go:588 +0x23c github.com/goplus/llgo/ssa.(*aPackage).abiTypeInit(0x14005bf2d80, 0x140077ca470, {0x104b4bba8, 0x140071cebc0}, 0x1) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:371 +0x1cc github.com/goplus/llgo/ssa.(*aBuilder).loadType(0x14007119560, {0x104b4bba8, 0x140071cebc0}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:423 +0xd8 github.com/goplus/llgo/ssa.(*aBuilder).abiType(0x14007119560, {0x104b4bba8?, 0x140071cebc0?}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:408 +0xb4 github.com/goplus/llgo/ssa.(*aBuilder).abiMethodOf(0x14007119560, 0x140059be6c0, {0x14002cd8d55, 0x7}, 0x140071ceb80) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:139 +0x1a8 github.com/goplus/llgo/ssa.(*aBuilder).abiInitNamed.func1() /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:248 +0x3e8 github.com/goplus/llgo/ssa.(*aPackage).abiTypeInit(0x14005bf2d80, 0x140077ca250, {0x104b4ba40, 0x140058d2690}, 0x1) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:391 +0x360 github.com/goplus/llgo/ssa.(*aBuilder).loadType(0x140071194d0, {0x104b4ba40, 0x140058d2690}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:423 +0xd8 github.com/goplus/llgo/ssa.(*aBuilder).abiType(0x140071194d0, {0x104b4bb58, 0x14005c0fb90}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:404 +0xa4 github.com/goplus/llgo/ssa.(*aBuilder).TypeAssert(0x140071194d0, {{0x104b4bb58?}, 0x140017e1320?}, 0x140021c5600, 0x0) /Users/aofei/workspace/goplus/llgo/ssa/interface.go:234 +0x134 github.com/goplus/llgo/cl.(*context).compileInstrOrValue(0x140074568f0, 0x140071194d0, {0x104b515a0, 0x140078e6070}, 0x50?) /Users/aofei/workspace/goplus/llgo/cl/compile.go:566 +0x484 github.com/goplus/llgo/cl.(*context).compileInstr(0x140074568f0, 0x140071194d0, {0x104b50188?, 0x140078e6070}) /Users/aofei/workspace/goplus/llgo/cl/compile.go:618 +0x500 github.com/goplus/llgo/cl.(*context).compileBlock(0x140074568f0, 0x140071194d0, 0x140078afd90, 0x0, 0x0, 0x0) /Users/aofei/workspace/goplus/llgo/cl/compile.go:311 +0x3ec github.com/goplus/llgo/cl.(*context).compileFuncDecl.func1() /Users/aofei/workspace/goplus/llgo/cl/compile.go:259 +0x344 github.com/goplus/llgo/cl.NewPackageEx(0x14000162588, 0x1400635a930, 0x140065e6000, {0x14005879ce0, 0xc, 0x16}) /Users/aofei/workspace/goplus/llgo/cl/compile.go:832 +0x56c github.com/goplus/llgo/internal/build.buildPkg(0x14007b59860, 0x140078c5860, 0x0) /Users/aofei/workspace/goplus/llgo/internal/build/build.go:433 +0x2a0 github.com/goplus/llgo/internal/build.buildAllPkgs(0x14007b59860, {0x14003b9a988?, 0x14006339d18?, 0x8?}, 0x0) /Users/aofei/workspace/goplus/llgo/internal/build/build.go:301 +0x350 github.com/goplus/llgo/internal/build.Do({0x14000112260?, 0x1?, 0x104a2536e?}, 0x140001414a0) /Users/aofei/workspace/goplus/llgo/internal/build/build.go:178 +0x748 github.com/goplus/llgo/cmd/internal/run.runCmdEx(0x104a36687?, {0x14000112260?, 0x104aa6e78?, 0x1047f7a60?}, 0x2) /Users/aofei/workspace/goplus/llgo/cmd/internal/run/run.go:72 +0x12c github.com/goplus/llgo/cmd/internal/run.runCmd(0x1400013c000?, {0x14000112260?, 0x0?, 0x0?}) /Users/aofei/workspace/goplus/llgo/cmd/internal/run/run.go:52 +0x24 main.main() /Users/aofei/workspace/goplus/llgo/cmd/llgo/llgo.go:88 +0x44c ```
Possibly introduced by #470. (/cc @visualfc)
Not a bug. It's caused by an outdated module version. Solved it by running go get github.com/goplus/llgo@main.
go get github.com/goplus/llgo@main
Case
Output
llgo run .
```sh $ llgo run . panic: interface conversion: types.Object is nil, not *types.Func goroutine 1 [running]: github.com/goplus/llgo/ssa.(*aPackage).rtFunc(0x14005bf2d80, {0x104a279c3, 0xe}) /Users/aofei/workspace/goplus/llgo/ssa/package.go:588 +0x23c github.com/goplus/llgo/ssa.(*aPackage).abiTypeInit(0x14005bf2d80, 0x140077ca470, {0x104b4bba8, 0x140071cebc0}, 0x1) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:371 +0x1cc github.com/goplus/llgo/ssa.(*aBuilder).loadType(0x14007119560, {0x104b4bba8, 0x140071cebc0}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:423 +0xd8 github.com/goplus/llgo/ssa.(*aBuilder).abiType(0x14007119560, {0x104b4bba8?, 0x140071cebc0?}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:408 +0xb4 github.com/goplus/llgo/ssa.(*aBuilder).abiMethodOf(0x14007119560, 0x140059be6c0, {0x14002cd8d55, 0x7}, 0x140071ceb80) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:139 +0x1a8 github.com/goplus/llgo/ssa.(*aBuilder).abiInitNamed.func1() /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:248 +0x3e8 github.com/goplus/llgo/ssa.(*aPackage).abiTypeInit(0x14005bf2d80, 0x140077ca250, {0x104b4ba40, 0x140058d2690}, 0x1) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:391 +0x360 github.com/goplus/llgo/ssa.(*aBuilder).loadType(0x140071194d0, {0x104b4ba40, 0x140058d2690}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:423 +0xd8 github.com/goplus/llgo/ssa.(*aBuilder).abiType(0x140071194d0, {0x104b4bb58, 0x14005c0fb90}) /Users/aofei/workspace/goplus/llgo/ssa/abitype.go:404 +0xa4 github.com/goplus/llgo/ssa.(*aBuilder).TypeAssert(0x140071194d0, {{0x104b4bb58?}, 0x140017e1320?}, 0x140021c5600, 0x0) /Users/aofei/workspace/goplus/llgo/ssa/interface.go:234 +0x134 github.com/goplus/llgo/cl.(*context).compileInstrOrValue(0x140074568f0, 0x140071194d0, {0x104b515a0, 0x140078e6070}, 0x50?) /Users/aofei/workspace/goplus/llgo/cl/compile.go:566 +0x484 github.com/goplus/llgo/cl.(*context).compileInstr(0x140074568f0, 0x140071194d0, {0x104b50188?, 0x140078e6070}) /Users/aofei/workspace/goplus/llgo/cl/compile.go:618 +0x500 github.com/goplus/llgo/cl.(*context).compileBlock(0x140074568f0, 0x140071194d0, 0x140078afd90, 0x0, 0x0, 0x0) /Users/aofei/workspace/goplus/llgo/cl/compile.go:311 +0x3ec github.com/goplus/llgo/cl.(*context).compileFuncDecl.func1() /Users/aofei/workspace/goplus/llgo/cl/compile.go:259 +0x344 github.com/goplus/llgo/cl.NewPackageEx(0x14000162588, 0x1400635a930, 0x140065e6000, {0x14005879ce0, 0xc, 0x16}) /Users/aofei/workspace/goplus/llgo/cl/compile.go:832 +0x56c github.com/goplus/llgo/internal/build.buildPkg(0x14007b59860, 0x140078c5860, 0x0) /Users/aofei/workspace/goplus/llgo/internal/build/build.go:433 +0x2a0 github.com/goplus/llgo/internal/build.buildAllPkgs(0x14007b59860, {0x14003b9a988?, 0x14006339d18?, 0x8?}, 0x0) /Users/aofei/workspace/goplus/llgo/internal/build/build.go:301 +0x350 github.com/goplus/llgo/internal/build.Do({0x14000112260?, 0x1?, 0x104a2536e?}, 0x140001414a0) /Users/aofei/workspace/goplus/llgo/internal/build/build.go:178 +0x748 github.com/goplus/llgo/cmd/internal/run.runCmdEx(0x104a36687?, {0x14000112260?, 0x104aa6e78?, 0x1047f7a60?}, 0x2) /Users/aofei/workspace/goplus/llgo/cmd/internal/run/run.go:72 +0x12c github.com/goplus/llgo/cmd/internal/run.runCmd(0x1400013c000?, {0x14000112260?, 0x0?, 0x0?}) /Users/aofei/workspace/goplus/llgo/cmd/internal/run/run.go:52 +0x24 main.main() /Users/aofei/workspace/goplus/llgo/cmd/llgo/llgo.go:88 +0x44c ```
Thoughts
Possibly introduced by #470. (/cc @visualfc)