github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/types/testdata/fixedbugs/issue49482.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package p 6 7 // The following is OK, per the special handling for type literals discussed in issue #49482. 8 type _[P *struct{}] struct{} 9 type _[P *int,] int 10 type _[P (*int),] int 11 12 const P = 2 // declare P to avoid noisy 'undefined' errors below. 13 14 // The following parse as invalid array types due to parsing ambiguitiues. 15 type _ [P *int /* ERROR "int (type) is not an expression" */ ]int 16 type _ [P /* ERROR "non-function P" */ (*int)]int 17 18 // Adding a trailing comma or an enclosing interface resolves the ambiguity. 19 type _[P *int,] int 20 type _[P (*int),] int 21 type _[P interface{*int}] int 22 type _[P interface{(*int)}] int 23 24 // The following parse correctly as valid generic types. 25 type _[P *struct{} | int] struct{} 26 type _[P *struct{} | ~int] struct{}