2012-02-16 21:48:57 -07:00
|
|
|
// errorcheck
|
2009-09-09 00:16:19 -06:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2020-03-29 02:12:06 -06:00
|
|
|
// Test that incorrect uses of the blank identifier are caught.
|
2012-02-18 19:19:43 -07:00
|
|
|
// Does not compile.
|
|
|
|
|
2019-06-22 13:56:49 -06:00
|
|
|
package _ // ERROR "invalid package name"
|
2009-09-09 00:16:19 -06:00
|
|
|
|
2013-03-04 09:01:42 -07:00
|
|
|
var t struct {
|
|
|
|
_ int
|
|
|
|
}
|
|
|
|
|
2015-11-15 15:32:30 -07:00
|
|
|
func (x int) _() { // ERROR "cannot define new methods on non-local type"
|
|
|
|
println(x)
|
|
|
|
}
|
|
|
|
|
2013-07-02 01:08:43 -06:00
|
|
|
type T struct {
|
|
|
|
_ []int
|
|
|
|
}
|
|
|
|
|
2009-09-09 00:16:19 -06:00
|
|
|
func main() {
|
2019-06-22 13:56:49 -06:00
|
|
|
_() // ERROR "cannot use .* as value"
|
|
|
|
x := _+1 // ERROR "cannot use .* as value"
|
2012-01-22 12:50:45 -07:00
|
|
|
_ = x
|
2020-11-30 22:38:49 -07:00
|
|
|
_ = t._ // ERROR "cannot refer to blank field|invalid use of|t._ undefined"
|
2013-07-02 01:08:43 -06:00
|
|
|
|
|
|
|
var v1, v2 T
|
2020-11-30 22:38:49 -07:00
|
|
|
_ = v1 == v2 // ERROR "cannot be compared|non-comparable|cannot compare v1 == v2"
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|