]> Cypherpunks repositories - gostls13.git/commitdiff
go/printer: do not panic on *ast.ParenExpr in combinesWithName
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Mon, 2 Sep 2024 12:37:51 +0000 (12:37 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 4 Sep 2024 13:34:59 +0000 (13:34 +0000)
Fixes #69206

Change-Id: I1b5a664c22d5739e2c6748d562591f57345b536e
GitHub-Last-Rev: 1798e2c65b3c2c0c1ef674b000dce2636c834783
GitHub-Pull-Request: golang/go#69208
Reviewed-on: https://go-review.googlesource.com/c/go/+/610115
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/go/printer/nodes.go
src/go/printer/testdata/generics.golden
src/go/printer/testdata/generics.input

index a4651e060868d23c44150bfeb334d8305d6c3848..495ec22031a3bce0bd364dc59565229e36ee513e 100644 (file)
@@ -411,9 +411,7 @@ func combinesWithName(x ast.Expr) bool {
        case *ast.BinaryExpr:
                return combinesWithName(x.X) && !isTypeElem(x.Y)
        case *ast.ParenExpr:
-               // name(x) combines but we are making sure at
-               // the call site that x is never parenthesized.
-               panic("unexpected parenthesized expression")
+               return combinesWithName(x.X)
        }
        return false
 }
index 7ddf20b3d18aaea1d7762714c456ad8e59c71316..89f5b88dbff6c60acbf2a3cd082cd5030341a616 100644 (file)
@@ -45,6 +45,8 @@ type _[P T | T] struct{}
 type _[P T | T | T | T] struct{}
 type _[P *T, _ any] struct{}
 type _[P *T,] struct{}
+type _[P *T,] struct{}
+type _[P ~int] struct{}
 type _[P *T, _ any] struct{}
 type _[P T] struct{}
 type _[P T, _ any] struct{}
index 4940f9319a6b432463670677674937c46739b3ff..bc24119c2e8b49b10d48c892c1cdd336ab8c8cd6 100644 (file)
@@ -42,6 +42,8 @@ type _[P T | T] struct{}
 type _[P T | T | T | T] struct{}
 type _[P *T, _ any] struct{}
 type _[P (*T),] struct{}
+type _[P ((*T)),] struct{}
+type _[P ((~int)),] struct{}
 type _[P (*T), _ any] struct{}
 type _[P (T),] struct{}
 type _[P (T), _ any] struct{}