]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/typecheck: more selective OPAREN skipping
authorMatthew Dempsky <mdempsky@google.com>
Wed, 20 Mar 2024 18:14:47 +0000 (11:14 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 20 Mar 2024 19:08:34 +0000 (19:08 +0000)
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>

src/cmd/compile/internal/typecheck/typecheck.go

index b22e45358ea83184905d8e826ec1192689430a0f..b4b9ecd8368b99c96208856e4e6aed435ab59b2b 100644 (file)
@@ -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)