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.
|
|
|
|
|
2012-02-18 19:19:43 -07:00
|
|
|
// Test that incorrect uses of the blank identifer are caught.
|
|
|
|
// Does not compile.
|
|
|
|
|
2009-09-09 00:16:19 -06:00
|
|
|
package _ // ERROR "invalid package name _"
|
|
|
|
|
2013-03-04 09:01:42 -07:00
|
|
|
var t struct {
|
|
|
|
_ int
|
|
|
|
}
|
|
|
|
|
2013-07-02 01:08:43 -06:00
|
|
|
type T struct {
|
|
|
|
_ []int
|
|
|
|
}
|
|
|
|
|
2009-09-09 00:16:19 -06:00
|
|
|
func main() {
|
2010-09-03 18:36:13 -06:00
|
|
|
_() // ERROR "cannot use _ as value"
|
|
|
|
x := _+1 // ERROR "cannot use _ as value"
|
2012-01-22 12:50:45 -07:00
|
|
|
_ = x
|
2013-03-04 09:01:42 -07:00
|
|
|
_ = t._ // ERROR "cannot refer to blank field"
|
2013-07-02 01:08:43 -06:00
|
|
|
|
|
|
|
var v1, v2 T
|
|
|
|
_ = v1 == v2 // ERROR "cannot be compared|non-comparable"
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|