mirror of https://github.com/golang/go.git
cmd/compile/internal/typecheck: more selective OPAREN skipping
Move the OPAREN skipping logic from typecheck into typecheck1, so that it only applies to ParenExprs with Typecheck()==0. This should allow CL 567695 to be re-landed, which uses ParenExprs as placeholders in the AST. Fixes #66261. Change-Id: I606b7bad0cf1c0447e60d6da68d1d66db00863f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/573095 Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
334835e6b3
commit
6af27c49bc
|
|
@ -160,11 +160,6 @@ func typecheck(n ir.Node, top int) (res ir.Node) {
|
||||||
lno := ir.SetPos(n)
|
lno := ir.SetPos(n)
|
||||||
defer func() { base.Pos = lno }()
|
defer func() { base.Pos = lno }()
|
||||||
|
|
||||||
// Skip over parens.
|
|
||||||
for n.Op() == ir.OPAREN {
|
|
||||||
n = n.(*ir.ParenExpr).X
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip typecheck if already done.
|
// Skip typecheck if already done.
|
||||||
// But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed.
|
// But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed.
|
||||||
if n.Typecheck() == 1 || n.Typecheck() == 3 {
|
if n.Typecheck() == 1 || n.Typecheck() == 3 {
|
||||||
|
|
@ -216,6 +211,11 @@ func indexlit(n ir.Node) ir.Node {
|
||||||
|
|
||||||
// typecheck1 should ONLY be called from typecheck.
|
// typecheck1 should ONLY be called from typecheck.
|
||||||
func typecheck1(n ir.Node, top int) ir.Node {
|
func typecheck1(n ir.Node, top int) ir.Node {
|
||||||
|
// Skip over parens.
|
||||||
|
for n.Op() == ir.OPAREN {
|
||||||
|
n = n.(*ir.ParenExpr).X
|
||||||
|
}
|
||||||
|
|
||||||
switch n.Op() {
|
switch n.Op() {
|
||||||
default:
|
default:
|
||||||
ir.Dump("typecheck", n)
|
ir.Dump("typecheck", n)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue