| 1 |
// errorcheck |
| 2 |
|
| 3 |
// Copyright 2009 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 |
// Test that incorrect uses of the blank identifier are caught. |
| 8 |
// Does not compile. |
| 9 |
|
| 10 |
package _ // ERROR "invalid package name" |
| 11 |
|
| 12 |
var t struct { |
| 13 |
_ int |
| 14 |
} |
| 15 |
|
| 16 |
func (x int) _() { // ERROR "methods on non-local type" |
| 17 |
println(x) |
| 18 |
} |
| 19 |
|
| 20 |
type T struct { |
| 21 |
_ []int |
| 22 |
} |
| 23 |
|
| 24 |
func main() { |
| 25 |
_() // ERROR "cannot use .* as value" |
| 26 |
x := _+1 // ERROR "cannot use .* as value" |
| 27 |
_ = x |
| 28 |
_ = t._ // ERROR "cannot refer to blank field|invalid use of" |
| 29 |
|
| 30 |
var v1, v2 T |
| 31 |
_ = v1 == v2 // ERROR "cannot be compared|non-comparable" |
| 32 |
} |