mirror of
https://github.com/golang/go
synced 2024-11-11 17:51:49 -07: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:
parent
794b0a0748
commit
700920bbb7
@ -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
|
||||
}
|
||||
|
2
src/go/printer/testdata/generics.golden
vendored
2
src/go/printer/testdata/generics.golden
vendored
@ -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{}
|
||||
|
2
src/go/printer/testdata/generics.input
vendored
2
src/go/printer/testdata/generics.input
vendored
@ -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{}
|
||||
|
Loading…
Reference in New Issue
Block a user