From 6af27c49bc875eb0b39e4aea098da98856e31372 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 20 Mar 2024 11:14:47 -0700 Subject: [PATCH] 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 Reviewed-by: Than McIntosh LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/internal/typecheck/typecheck.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index b22e45358e..b4b9ecd836 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -160,11 +160,6 @@ func typecheck(n ir.Node, top int) (res ir.Node) { lno := ir.SetPos(n) defer func() { base.Pos = lno }() - // Skip over parens. - for n.Op() == ir.OPAREN { - n = n.(*ir.ParenExpr).X - } - // Skip typecheck if already done. // But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed. 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. 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() { default: ir.Dump("typecheck", n) -- 2.50.0