mirror of https://github.com/golang/go.git
go/types, types2: report "undefined: p.x" instead of "x not declared by package p"
This matches the compiler's long-standing behavior. For #55326. Change-Id: Icd946b031b1b6e65498fb52bceb4a53807732463 Reviewed-on: https://go-review.googlesource.com/c/go/+/432556 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
2da95e0ec8
commit
17f83e3473
|
|
@ -465,7 +465,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, def *Named) {
|
|||
}
|
||||
}
|
||||
if exp == nil {
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "%s not declared by package C", sel)
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "undefined: %s", syntax.Expr(e)) // cast to syntax.Expr to silence vet
|
||||
goto Error
|
||||
}
|
||||
check.objDecl(exp, nil)
|
||||
|
|
@ -473,11 +473,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, def *Named) {
|
|||
exp = pkg.scope.Lookup(sel)
|
||||
if exp == nil {
|
||||
if !pkg.fake {
|
||||
if check.conf.CompilerErrorMessages {
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "undefined: %s.%s", pkg.name, sel)
|
||||
} else {
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "%s not declared by package %s", sel, pkg.name)
|
||||
}
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "undefined: %s", syntax.Expr(e))
|
||||
}
|
||||
goto Error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, def *Named) {
|
|||
}
|
||||
}
|
||||
if exp == nil {
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "%s not declared by package C", sel)
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "undefined: %s", ast.Expr(e)) // cast to ast.Expr to silence vet
|
||||
goto Error
|
||||
}
|
||||
check.objDecl(exp, nil)
|
||||
|
|
@ -477,7 +477,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, def *Named) {
|
|||
exp = pkg.scope.Lookup(sel)
|
||||
if exp == nil {
|
||||
if !pkg.fake {
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "%s not declared by package %s", sel, pkg.name)
|
||||
check.errorf(e.Sel, _UndeclaredImportedName, "undefined: %s", ast.Expr(e))
|
||||
}
|
||||
goto Error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ var (
|
|||
t13 int = a /* ERROR "shifted operand" */ << d
|
||||
t14 int = i << j
|
||||
t15 math /* ERROR "not in selector" */
|
||||
t16 math.xxx /* ERROR "not declared" */
|
||||
t16 math.xxx /* ERROR "undefined" */
|
||||
t17 math /* ERROR "not a type" */ .Pi
|
||||
t18 float64 = math.Pi * 10.0
|
||||
t19 int = t1 /* ERROR "cannot call" */ ()
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ func issue10979() {
|
|||
nosuchtype /* ERROR undefined: nosuchtype */
|
||||
}
|
||||
type _ interface {
|
||||
fmt.Nosuchtype /* ERROR Nosuchtype not declared by package fmt */
|
||||
fmt.Nosuchtype /* ERROR undefined: fmt\.Nosuchtype */
|
||||
}
|
||||
type _ interface {
|
||||
nosuchpkg /* ERROR undefined: nosuchpkg */ .Nosuchtype
|
||||
|
|
|
|||
Loading…
Reference in New Issue