mirror of
https://github.com/golang/go
synced 2024-11-22 05:24:39 -07:00
go/printer: do not panic on *ast.ParenExpr
This commit is contained in:
parent
fc9f02c7ae
commit
1798e2c65b
@ -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