| 1 |
// -lang=go1.25 |
| 2 |
|
| 3 |
// Copyright 2025 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
package p |
| 8 |
|
| 9 |
import "strings" |
| 10 |
|
| 11 |
type T int |
| 12 |
type G[P any] struct{} |
| 13 |
|
| 14 |
var x T |
| 15 |
|
| 16 |
// Verify that we don't get a version error when there's another error present in new(expr). |
| 17 |
|
| 18 |
func f() { |
| 19 |
_ = new(U /* ERROR "undefined: U" */) |
| 20 |
_ = new(strings.BUILDER /* ERROR "undefined: strings.BUILDER (but have Builder)" */) |
| 21 |
_ = new(T) // ok |
| 22 |
_ = new(G[int]) // ok |
| 23 |
_ = new(G /* ERROR "cannot use generic type G without instantiation" */) |
| 24 |
_ = new(nil /* ERROR "use of untyped nil in argument to new" */) |
| 25 |
_ = new(comparable /* ERROR "cannot use type comparable outside a type constraint" */) |
| 26 |
_ = new(new /* ERROR "new (built-in) must be called" */) |
| 27 |
_ = new(panic /* ERROR "panic(0) (no value) used as value or type" */ (0)) |
| 28 |
} |