mirror of
https://github.com/golang/go
synced 2024-09-18 15:32:18 +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
|
@ -31,9 +31,13 @@ func (check *Checker) ident(x *operand, e *syntax.Name, def *Named, wantType boo
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
if e.Value == "_" {
|
if e.Value == "_" {
|
||||||
check.errorf(e, "cannot use _ as value or type")
|
check.errorf(e, "cannot use _ as value or type")
|
||||||
|
} else {
|
||||||
|
if check.conf.CompilerErrorMessages {
|
||||||
|
check.errorf(e, "undefined: %s", e.Value)
|
||||||
} else {
|
} else {
|
||||||
check.errorf(e, "undeclared name: %s", e.Value)
|
check.errorf(e, "undeclared name: %s", e.Value)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
check.recordUse(e, obj)
|
check.recordUse(e, obj)
|
||||||
|
|
|
@ -10,8 +10,8 @@ package tparam1
|
||||||
|
|
||||||
// The predeclared identifier "any" is only visible as a constraint
|
// The predeclared identifier "any" is only visible as a constraint
|
||||||
// in a type parameter list.
|
// in a type parameter list.
|
||||||
var _ any // ERROR "undeclared"
|
var _ any // ERROR "undefined"
|
||||||
func _(_ any) // ERROR "undeclared"
|
func _(_ any) // ERROR "undefined"
|
||||||
type _[_ any /* ok here */ ] struct{}
|
type _[_ any /* ok here */ ] struct{}
|
||||||
|
|
||||||
const N = 10
|
const N = 10
|
||||||
|
|
Loading…
Reference in a new issue