return pkg.Name()
}
-func maybeTypecheck(t *testing.T, path, source string, info *Info) string {
+func mayTypecheck(t *testing.T, path, source string, info *Info) string {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, path, source, 0)
if f == nil { // ignore errors unless f is nil
for _, test := range tests {
info := Info{Types: make(map[ast.Expr]TypeAndValue)}
- name := maybeTypecheck(t, "TypesInfo", test.src, &info)
+ name := mayTypecheck(t, "TypesInfo", test.src, &info)
// look for expression type
var typ Type
check.recordDef(ident, obj)
}
} else {
- check.expr(&operand{}, lhs)
+ check.useLHS(lhs)
check.errorf(lhs.Pos(), "cannot declare %s", lhs)
}
if obj == nil {
check.conversion(x, T)
}
default:
- for _, arg := range e.Args {
- check.expr(&operand{}, arg)
- }
+ check.use(e.Args...)
check.errorf(e.Args[n-1].Pos(), "too many arguments in conversion to %s", T)
}
x.expr = e
continue
}
key, _ := kv.Key.(*ast.Ident)
+ // do all possible checks early (before exiting due to errors)
+ // so we don't drop information on the floor
check.expr(x, kv.Value)
if key == nil {
check.errorf(kv.Pos(), "invalid field name %s in struct literal", kv.Key)