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>
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])
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])
--- /dev/null
+// 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
+)