mirror of
https://github.com/golang/go
synced 2024-11-27 02:11:17 -07:00
72ad2f44ea
Added a new flag -G to run. Setting -G (as in: go run run.go -G) will run tests marked with "errorcheck" (and no other flags) also with the compiler using the new typechecker. Many tests don't pass yet (due to discrepancies in error messages). The top-level tests in the test directory which don't pass yet have been explicitly excluded, permitting to see the current status. Future CLs will bring error messages in sync and eventually all tests should pass. Change-Id: I7caf5eff413e173f68d092af4bbe458434718d74 Reviewed-on: https://go-review.googlesource.com/c/go/+/274313 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
33 lines
742 B
Go
33 lines
742 B
Go
// errorcheck
|
|
|
|
// 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.
|
|
|
|
// Test that incorrect uses of the blank identifier are caught.
|
|
// Does not compile.
|
|
|
|
package _ // ERROR "invalid package name"
|
|
|
|
var t struct {
|
|
_ int
|
|
}
|
|
|
|
func (x int) _() { // ERROR "cannot define new methods on non-local type"
|
|
println(x)
|
|
}
|
|
|
|
type T struct {
|
|
_ []int
|
|
}
|
|
|
|
func main() {
|
|
_() // ERROR "cannot use .* as value"
|
|
x := _+1 // ERROR "cannot use .* as value"
|
|
_ = x
|
|
_ = t._ // ERROR "cannot refer to blank field|invalid use of|t._ undefined"
|
|
|
|
var v1, v2 T
|
|
_ = v1 == v2 // ERROR "cannot be compared|non-comparable|cannot compare v1 == v2"
|
|
}
|