1
0
mirror of https://github.com/golang/go synced 2024-09-23 07:23:18 -06:00

go/printer: do not panic on *ast.ParenExpr in combinesWithName

Fixes #69206

Change-Id: I1b5a664c22d5739e2c6748d562591f57345b536e
GitHub-Last-Rev: 1798e2c65b
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>
This commit is contained in:
Mateusz Poliwczak 2024-09-02 12:37:51 +00:00 committed by Gopher Robot
parent 794b0a0748
commit 700920bbb7
3 changed files with 5 additions and 3 deletions

View 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
}

View 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{}

View 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{}