1
0
mirror of https://github.com/golang/go synced 2024-11-11 17:51:49 -07:00

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

This commit is contained in:
Mateusz Poliwczak 2024-09-02 14:31:32 +02:00
parent fc9f02c7ae
commit 1798e2c65b
3 changed files with 5 additions and 3 deletions

View File

@ -411,9 +411,7 @@ func combinesWithName(x ast.Expr) bool {
case *ast.BinaryExpr: case *ast.BinaryExpr:
return combinesWithName(x.X) && !isTypeElem(x.Y) return combinesWithName(x.X) && !isTypeElem(x.Y)
case *ast.ParenExpr: case *ast.ParenExpr:
// name(x) combines but we are making sure at return combinesWithName(x.X)
// the call site that x is never parenthesized.
panic("unexpected parenthesized expression")
} }
return false return false
} }

View File

@ -45,6 +45,8 @@ type _[P T | T] struct{}
type _[P T | T | T | T] struct{} type _[P T | T | T | T] struct{}
type _[P *T, _ any] struct{} type _[P *T, _ any] struct{}
type _[P *T,] struct{} type _[P *T,] struct{}
type _[P *T,] struct{}
type _[P ~int] struct{}
type _[P *T, _ any] struct{} type _[P *T, _ any] struct{}
type _[P T] struct{} type _[P T] struct{}
type _[P T, _ any] 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 | T | T | T] struct{}
type _[P *T, _ any] struct{} type _[P *T, _ any] struct{}
type _[P (*T),] struct{} type _[P (*T),] struct{}
type _[P ((*T)),] struct{}
type _[P ((~int)),] struct{}
type _[P (*T), _ any] struct{} type _[P (*T), _ any] struct{}
type _[P (T),] struct{} type _[P (T),] struct{}
type _[P (T), _ any] struct{} type _[P (T), _ any] struct{}