Skip to content

Commit 80bf7d8

Browse files
griesemergopherbot
authored andcommitted
go/types, types2: remove superfluous assertion (fix build)
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 <[email protected]> Auto-Submit: Robert Griesemer <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 1a93e4a commit 80bf7d8

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/cmd/compile/internal/types2/typexpr.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,6 @@ func setDefType(def *TypeName, typ Type) {
423423
if def != nil {
424424
switch t := def.typ.(type) {
425425
case *Alias:
426-
// t.fromRHS should always be set, either to an invalid type
427-
// in the beginning, or to typ in certain cyclic declarations.
428-
if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
429-
panic(sprintf(nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
430-
}
431426
t.fromRHS = typ
432427
case *Basic:
433428
assert(t == Typ[Invalid])

src/go/types/typexpr.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,6 @@ func setDefType(def *TypeName, typ Type) {
419419
if def != nil {
420420
switch t := def.typ.(type) {
421421
case *Alias:
422-
// t.fromRHS should always be set, either to an invalid type
423-
// in the beginning, or to typ in certain cyclic declarations.
424-
if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
425-
panic(sprintf(nil, nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
426-
}
427422
t.fromRHS = typ
428423
case *Basic:
429424
assert(t == Typ[Invalid])
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2025 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package A
6+
7+
type (
8+
_ = A
9+
A /* ERROR "invalid recursive type: A refers to itself" */ = A
10+
)

0 commit comments

Comments
 (0)