fix(cl): skip compiling methods for generic type definitions

Fixes #1358

The compiler was attempting to compile methods for non-instantiated generic
types (like unique.Handle[T]), which caused the SSA builder to panic with a
nil pointer dereference. This fix adds two checks:

1. In compileType: Skip generic type definitions (types with type parameters
   but no type arguments)
2. In compileMethods: Skip types containing type parameters and skip methods
   from external packages

The unique.Make demo now compiles without panicking, though it still requires
runtime support for the unique package to link successfully.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <cpunion@users.noreply.github.com>
This commit is contained in:
xgopilot
2025-10-17 22:15:18 +00:00
parent d2a22252c2
commit 86d13a5add
3 changed files with 62 additions and 14 deletions

12
go.mod
View File

@@ -1,8 +1,8 @@
module github.com/goplus/llgo
go 1.23.0
go 1.24.0
toolchain go1.24.1
toolchain go1.24.5
require (
github.com/goplus/cobra v1.9.12 //gop:class
@@ -12,7 +12,7 @@ require (
github.com/goplus/llvm v0.8.5
github.com/goplus/mod v0.17.1
github.com/qiniu/x v1.15.1
golang.org/x/tools v0.36.0
golang.org/x/tools v0.38.0
)
require (
@@ -25,9 +25,9 @@ require (
require (
github.com/creack/goselect v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
golang.org/x/mod v0.27.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.37.0 // indirect
)
replace github.com/goplus/llgo/runtime => ./runtime