mirror of
https://github.com/golang/go
synced 2024-11-11 18:21:40 -07:00
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 <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
51d8d351c1
commit
9e6b1fcd0a
@ -689,7 +689,7 @@ func (p *noder) expr(expr syntax.Expr) ir.Node {
|
|||||||
if expr.Kind == syntax.RuneLit {
|
if expr.Kind == syntax.RuneLit {
|
||||||
n.SetType(types.UntypedRune)
|
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
|
return n
|
||||||
case *syntax.CompositeLit:
|
case *syntax.CompositeLit:
|
||||||
n := ir.NewCompLitExpr(p.pos(expr), ir.OCOMPLIT, p.typeExpr(expr.Type), nil)
|
n := ir.NewCompLitExpr(p.pos(expr), ir.OCOMPLIT, p.typeExpr(expr.Type), nil)
|
||||||
|
@ -482,7 +482,9 @@ func typecheck1(n ir.Node, top int) ir.Node {
|
|||||||
|
|
||||||
case ir.OLITERAL:
|
case ir.OLITERAL:
|
||||||
if n.Sym() == nil && n.Type() == nil {
|
if n.Sym() == nil && n.Type() == nil {
|
||||||
base.Fatalf("literal missing type: %v", n)
|
if !n.Diag() {
|
||||||
|
base.Fatalf("literal missing type: %v", n)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// errorcheck
|
// errorcheck -d=panic
|
||||||
|
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// errorcheck
|
// errorcheck -d=panic
|
||||||
|
|
||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
Loading…
Reference in New Issue
Block a user