github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/types/testdata/fixedbugs/issue51658.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 // This test checks syntax errors which differ between 6 // go/parser and the syntax package. 7 // TODO: consolidate eventually 8 9 package p 10 11 type F { // ERRORx "expected type|type declaration" 12 float64 13 } // ERRORx "expected declaration|non-declaration statement" 14 15 func _[T F | int](x T) { 16 _ = x == 0 // don't crash when recording type of 0 17 } 18 19 // test case from issue 20 21 type FloatType { // ERRORx "expected type|type declaration" 22 float32 | float64 23 } // ERRORx "expected declaration|non-declaration statement" 24 25 type IntegerType interface { 26 int8 | int16 | int32 | int64 | int | 27 uint8 | uint16 | uint32 | uint64 | uint 28 } 29 30 type ComplexType interface { 31 complex64 | complex128 32 } 33 34 type Number interface { 35 FloatType | IntegerType | ComplexType 36 } 37 38 func GetDefaultNumber[T Number](value, defaultValue T) T { 39 if value == 0 { 40 return defaultValue 41 } 42 return value 43 }