mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
[dev.typeparams] cmd/compile/internal/types2: set compiler error message for undeclared variable
Change-Id: Ie2950cdc5406915935f114bfd97ef03d965f9069 Reviewed-on: https://go-review.googlesource.com/c/go/+/274616 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
bdc4ffe9a8
commit
036245862a
2 changed files with 7 additions and 3 deletions
|
@ -32,7 +32,11 @@ func (check *Checker) ident(x *operand, e *syntax.Name, def *Named, wantType boo
|
|||
if e.Value == "_" {
|
||||
check.errorf(e, "cannot use _ as value or type")
|
||||
} else {
|
||||
check.errorf(e, "undeclared name: %s", e.Value)
|
||||
if check.conf.CompilerErrorMessages {
|
||||
check.errorf(e, "undefined: %s", e.Value)
|
||||
} else {
|
||||
check.errorf(e, "undeclared name: %s", e.Value)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ package tparam1
|
|||
|
||||
// The predeclared identifier "any" is only visible as a constraint
|
||||
// in a type parameter list.
|
||||
var _ any // ERROR "undeclared"
|
||||
func _(_ any) // ERROR "undeclared"
|
||||
var _ any // ERROR "undefined"
|
||||
func _(_ any) // ERROR "undefined"
|
||||
type _[_ any /* ok here */ ] struct{}
|
||||
|
||||
const N = 10
|
||||
|
|
Loading…
Reference in a new issue