From c082f9fee0e08ac5ea6498ade1153fb6e68f7c72 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 4 Mar 2021 15:06:38 +0700 Subject: [PATCH] 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 Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/typecheck/typecheck.go | 6 +++++- test/fixedbugs/issue22389.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index 548c1af85c..30632ac18b 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -446,7 +446,11 @@ func typecheck(n ir.Node, top int) (res ir.Node) { case top&(ctxType|ctxExpr) == ctxType && n.Op() != ir.OTYPE && n.Op() != ir.ONONAME && (t != nil || n.Op() == ir.ONAME): base.Errorf("%v is not a type", n) if t != nil { - n.SetType(nil) + if n.Op() == ir.ONAME { + t.SetBroke(true) + } else { + n.SetType(nil) + } } } diff --git a/test/fixedbugs/issue22389.go b/test/fixedbugs/issue22389.go index 75dc285403..81e6d94e65 100644 --- a/test/fixedbugs/issue22389.go +++ b/test/fixedbugs/issue22389.go @@ -1,4 +1,4 @@ -// errorcheck +// errorcheck -d=panic // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style