Skip to content

Commit c082f9f

Browse files
committed
cmd/compile: do not set ONAME type when evaluated in type context
Updates #43311 Change-Id: I26e397d071b434256dab0cc7fff9d134b80bd6e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/298711 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent fbee173 commit c082f9f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,11 @@ func typecheck(n ir.Node, top int) (res ir.Node) {
446446
case top&(ctxType|ctxExpr) == ctxType && n.Op() != ir.OTYPE && n.Op() != ir.ONONAME && (t != nil || n.Op() == ir.ONAME):
447447
base.Errorf("%v is not a type", n)
448448
if t != nil {
449-
n.SetType(nil)
449+
if n.Op() == ir.ONAME {
450+
t.SetBroke(true)
451+
} else {
452+
n.SetType(nil)
453+
}
450454
}
451455

452456
}

test/fixedbugs/issue22389.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// errorcheck
1+
// errorcheck -d=panic
22

33
// Copyright 2017 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

0 commit comments

Comments
 (0)