diff --git a/go/types/check.go b/go/types/check.go index 0032726e59c..472efe2da8f 100644 --- a/go/types/check.go +++ b/go/types/check.go @@ -50,12 +50,14 @@ type checker struct { func (check *checker) callIdent(id *ast.Ident, obj Object) { if f := check.ctxt.Ident; f != nil { + assert(id != nil) f(id, obj) } } func (check *checker) callImplicitObj(node ast.Node, obj Object) { if f := check.ctxt.ImplicitObj; f != nil { + assert(node != nil && obj != nil) f(node, obj) } } diff --git a/go/types/expr.go b/go/types/expr.go index 157392b93fa..1c1708b9879 100644 --- a/go/types/expr.go +++ b/go/types/expr.go @@ -1018,6 +1018,7 @@ func (check *checker) callExpr(x *operand) { // This is not the case yet. if check.ctxt.Expr != nil { + assert(x.expr != nil && typ != nil) check.ctxt.Expr(x.expr, typ, val) } } @@ -1536,9 +1537,17 @@ func (check *checker) rawExpr(x *operand, e ast.Expr, hint Type, iota int, cycle case *ast.CallExpr: check.exprOrType(x, e.Fun, iota, false) if x.mode == invalid { + // We don't have a valid call or conversion but we have list of arguments. + // Typecheck them independently for better partial type information in + // the presence of type errors. + for _, arg := range e.Args { + check.expr(x, arg, nil, iota) + } goto Error + } else if x.mode == typexpr { check.conversion(x, e, x.typ, iota) + } else if sig, ok := x.typ.Underlying().(*Signature); ok { // check parameters