From 9e6b1fcd0a42db0f4699ff17e3b248e563f7eee4 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 4 Mar 2021 22:24:58 +0700 Subject: cmd/compile: do not report error for invalid constant Invalid constant was already reported by noder, so don't re-check in typecheck, which lead to compiler crashing. Updates #43311 Change-Id: I48e2f540601cef725c1ff628c066ed15d848e771 Reviewed-on: https://go-review.googlesource.com/c/go/+/298713 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/noder/noder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/compile/internal/noder/noder.go') diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go index 8c456e4561..4c7c9fc322 100644 --- a/src/cmd/compile/internal/noder/noder.go +++ b/src/cmd/compile/internal/noder/noder.go @@ -689,7 +689,7 @@ func (p *noder) expr(expr syntax.Expr) ir.Node { if expr.Kind == syntax.RuneLit { n.SetType(types.UntypedRune) } - n.SetDiag(expr.Bad) // avoid follow-on errors if there was a syntax error + n.SetDiag(expr.Bad || n.Val().Kind() == constant.Unknown) // avoid follow-on errors if there was a syntax error return n case *syntax.CompositeLit: n := ir.NewCompLitExpr(p.pos(expr), ir.OCOMPLIT, p.typeExpr(expr.Type), nil) -- cgit v1.3