]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: remove superfluous assertion (fix build)
authorRobert Griesemer <gri@golang.org>
Fri, 17 Jan 2025 00:08:26 +0000 (16:08 -0800)
committerGopher Robot <gobot@golang.org>
Fri, 17 Jan 2025 14:41:53 +0000 (06:41 -0800)
Remove an assertion that was overly restrictive and hard to get
correct under all circumstances (i.e., in the presence of incorrect)
code. This matches the code for *Named types in that specific switch.

Fixes #71284.

Change-Id: Ifccf8b73dc70cac9cb1c8b24946d16851d511454
Reviewed-on: https://go-review.googlesource.com/c/go/+/643255
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/types2/typexpr.go
src/go/types/typexpr.go
src/internal/types/testdata/fixedbugs/issue71284.go [new file with mode: 0644]

index fa6a6f622af7cfd8ce892b7ffc3a01dd3a919fc9..e9b5ca9aa6c329068d2917da2dbf5dd96fca3ff9 100644 (file)
@@ -423,11 +423,6 @@ func setDefType(def *TypeName, typ Type) {
        if def != nil {
                switch t := def.typ.(type) {
                case *Alias:
-                       // t.fromRHS should always be set, either to an invalid type
-                       // in the beginning, or to typ in certain cyclic declarations.
-                       if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
-                               panic(sprintf(nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
-                       }
                        t.fromRHS = typ
                case *Basic:
                        assert(t == Typ[Invalid])
index e560f2c131bd37db9e57ee8015a3fe7a7f9daa0f..7928ed8ef368de6363b5376faf9c633fc1808b9b 100644 (file)
@@ -419,11 +419,6 @@ func setDefType(def *TypeName, typ Type) {
        if def != nil {
                switch t := def.typ.(type) {
                case *Alias:
-                       // t.fromRHS should always be set, either to an invalid type
-                       // in the beginning, or to typ in certain cyclic declarations.
-                       if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
-                               panic(sprintf(nil, nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
-                       }
                        t.fromRHS = typ
                case *Basic:
                        assert(t == Typ[Invalid])
diff --git a/src/internal/types/testdata/fixedbugs/issue71284.go b/src/internal/types/testdata/fixedbugs/issue71284.go
new file mode 100644 (file)
index 0000000..4b73087
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package A
+
+type (
+       _ = A
+       A /* ERROR "invalid recursive type: A refers to itself" */ = A
+)