diff --git a/go/types/expr.go b/go/types/expr.go index 2bf8f26..6addce6 100644 --- a/go/types/expr.go +++ b/go/types/expr.go @@ -1145,11 +1145,14 @@ func (check *checker) rawExpr(x *operand, e ast.Expr, hint Type, iota int, cycle if ident, ok := e.X.(*ast.Ident); ok { if pkg, ok := check.lookup(ident).(*Package); ok { exp := pkg.Scope.Lookup(sel) - // gcimported package scopes contain non-exported - // objects such as types used in partially exported - // objects - do not accept them - if exp == nil || !ast.IsExported(exp.GetName()) { - check.errorf(e.Pos(), "cannot refer to unexported %s", e) + if exp == nil { + check.errorf(e.Pos(), "%s not declared by package %s", sel, ident) + goto Error + } else if !ast.IsExported(exp.GetName()) { + // gcimported package scopes contain non-exported + // objects such as types used in partially exported + // objects - do not accept them + check.errorf(e.Pos(), "%s not exported by package %s", sel, ident) goto Error } check.register(e.Sel, exp) diff --git a/go/types/testdata/decls0.src b/go/types/testdata/decls0.src index f0115bd..c3a17ea 100644 --- a/go/types/testdata/decls0.src +++ b/go/types/testdata/decls0.src @@ -18,7 +18,7 @@ import ( // reflect.flag must not be visible in this package type flag int -type _ reflect /* ERROR "cannot refer to unexported" */ .flag +type _ reflect /* ERROR "not exported" */ .flag // dot-imported exported objects may conflict with local objects type Value /* ERROR "redeclared in this block by dot-import" */ struct{} diff --git a/go/types/testdata/decls1.src b/go/types/testdata/decls1.src index 79c9e65..b3ad5ac 100644 --- a/go/types/testdata/decls1.src +++ b/go/types/testdata/decls1.src @@ -64,7 +64,7 @@ var ( t13 int = a /* ERROR "shifted operand" */ << d t14 int = i << j /* ERROR "must be unsigned" */ t15 math /* ERROR "not in selector" */ - t16 math /* ERROR "unexported" */ .xxx + t16 math /* ERROR "not declared" */ .xxx t17 math /* ERROR "not a type" */ .Pi t18 float64 = math.Pi * 10.0 t19 int = t1 /* ERROR "cannot call" */ ()