Skip to content

Commit 76ba1a5

Browse files
mdempskycherrymui
authored andcommitted
[release-branch.go1.18] cmd/compile: revert "backport fix for #51840"
This reverts CL 405436 (commit e1b14f5). Fixes #53883. Updates #51840. Change-Id: Ide5a9568a7ae5b449ef154c29b69699a7e4b3f6b Reviewed-on: https://go-review.googlesource.com/c/go/+/417616 Reviewed-by: David Chase <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Jenny Rakoczy <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent ed50277 commit 76ba1a5

File tree

2 files changed

+4
-50
lines changed

2 files changed

+4
-50
lines changed

src/cmd/compile/internal/typecheck/stmt.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,13 @@ func assign(stmt ir.Node, lhs, rhs []ir.Node) {
127127

128128
checkLHS := func(i int, typ *types.Type) {
129129
lhs[i] = Resolve(lhs[i])
130-
if base.Flag.G != 0 || base.Debug.Unified != 0 {
131-
// New logic added in CL 403837 for Go 1.19, which only has -G=3 and unified IR.
132-
if n := lhs[i]; typ != nil && ir.DeclaredBy(n, stmt) && n.Type() == nil {
133-
base.Assertf(typ.Kind() == types.TNIL, "unexpected untyped nil")
130+
if n := lhs[i]; typ != nil && ir.DeclaredBy(n, stmt) && n.Name().Ntype == nil {
131+
if typ.Kind() != types.TNIL {
134132
n.SetType(defaultType(typ))
135-
}
136-
} else {
137-
// Original logic from Go 1.18, which is still needed for -G=0.
138-
if n := lhs[i]; typ != nil && ir.DeclaredBy(n, stmt) && n.Name().Ntype == nil {
139-
if typ.Kind() != types.TNIL {
140-
n.SetType(defaultType(typ))
141-
} else {
142-
base.Errorf("use of untyped nil")
143-
}
133+
} else {
134+
base.Errorf("use of untyped nil")
144135
}
145136
}
146-
147137
if lhs[i].Typecheck() == 0 {
148138
lhs[i] = AssignExpr(lhs[i])
149139
}

test/typeparam/issue51840.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)