diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2025-04-25 19:13:52 +0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-05-22 11:23:35 -0700 |
| commit | b1f259b1b42f055863a67492e7815ec752eae56b (patch) | |
| tree | b750114613862a7dd71807a7b4fd3a14841e17e5 /src/cmd/compile | |
| parent | 155ba387a93fddbd6ced288fe539a55c31b2597e (diff) | |
| download | go-b1f259b1b42f055863a67492e7815ec752eae56b.tar.xz | |
cmd/compile: fix ICE with recursive alias type parameter
CL 585399 fixed an initialization loop during IR contruction that
involving alias type, by avoiding publishing alias declarations until
the RHS type expression has been constructed.
There's an assertion to ensure that the alias's type must be the same
during the initialization. However, that assertion is too strict, since
we may construct different instances of the same type, if the type is an
instantination of generic type.
To fix this, we could use types.IdenticalStrict to ensure that these
types matching exactly.
Updates #66873.
Updates #73309.
Change-Id: I2559bed37e21615854333fb1057d7349406e6a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/668175
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/cmd/compile')
| -rw-r--r-- | src/cmd/compile/internal/noder/reader.go | 2 | ||||
| -rw-r--r-- | src/cmd/compile/internal/types2/stdlib_test.go | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index 05052651c6..95054a4f8b 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -762,7 +762,7 @@ func (pr *pkgReader) objIdxMayFail(idx index, implicits, explicits []*types.Type if hack { if sym.Def != nil { name = sym.Def.(*ir.Name) - assert(name.Type() == typ) + assert(types.IdenticalStrict(name.Type(), typ)) return name, nil } sym.Def = name diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go index 6966bb94b0..4de698baaf 100644 --- a/src/cmd/compile/internal/types2/stdlib_test.go +++ b/src/cmd/compile/internal/types2/stdlib_test.go @@ -332,6 +332,7 @@ func TestStdFixed(t *testing.T) { "issue49814.go", // go/types does not have constraints on array size "issue56103.go", // anonymous interface cycles; will be a type checker error in 1.22 "issue52697.go", // types2 does not have constraints on stack size + "issue73309.go", // this test requires GODEBUG=gotypesalias=1 // These tests requires runtime/cgo.Incomplete, which is only available on some platforms. // However, types2 does not know about build constraints. |
