diff options
author | Robert Griesemer <gri@golang.org> | 2021-03-30 23:12:48 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-04-06 19:00:26 +0000 |
commit | d6a90d06d2883c6ae4bbd9bff2aafc338cc8f339 (patch) | |
tree | bf9f448214756774a485055936768a4b8118f64b /src/cmd/compile/internal/types2/call.go | |
parent | 3a30381b2110f15de85514609965b7cafd90aec0 (diff) | |
download | go-d6a90d06d2883c6ae4bbd9bff2aafc338cc8f339.tar.gz go-d6a90d06d2883c6ae4bbd9bff2aafc338cc8f339.zip |
cmd/compile/internal/types2: simplify Checker.Call
Now that we use square brackets for instantiations, we
can tell type arguments from ordinary arguments without
"guessing" which permits a simpler implementation.
Specifically, replace use of Checker.exprOrTypeList with
Checker.exprList, and delete Checker.exprOrTypeList and
Checker.multiExprOrType.
Disable a test for an (esoteric) failure due to an
unrelated problem with error matching when running
the test.
Change-Id: I17f18fffc32f03fa90d93a68ebf56e5f2fcc9dab
Reviewed-on: https://go-review.googlesource.com/c/go/+/306171
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/call.go')
-rw-r--r-- | src/cmd/compile/internal/types2/call.go | 62 |
1 files changed, 1 insertions, 61 deletions
diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index 38e9015248..20649bed99 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -146,13 +146,7 @@ func (check *Checker) call(x *operand, call *syntax.CallExpr) exprKind { } // evaluate arguments - args, ok := check.exprOrTypeList(call.ArgList) - if !ok { - x.mode = invalid - x.expr = call - return expression - } - + args, _ := check.exprList(call.ArgList, false) sig = check.arguments(call, sig, args) // determine result @@ -183,60 +177,6 @@ func (check *Checker) call(x *operand, call *syntax.CallExpr) exprKind { } } -// exprOrTypeList returns a list of operands and reports an error if the -// list contains a mix of values and types (ignoring invalid operands). -// TODO(gri) Now we can split this into exprList and typeList. -func (check *Checker) exprOrTypeList(elist []syntax.Expr) (xlist []*operand, ok bool) { - ok = true - - switch len(elist) { - case 0: - // nothing to do - - case 1: - // single (possibly comma-ok) value or type, or function returning multiple values - e := elist[0] - var x operand - check.multiExprOrType(&x, e) - if t, ok := x.typ.(*Tuple); ok && x.mode != invalid && x.mode != typexpr { - // multiple values - xlist = make([]*operand, t.Len()) - for i, v := range t.vars { - xlist[i] = &operand{mode: value, expr: e, typ: v.typ} - } - break - } - - check.instantiatedOperand(&x) - - // exactly one (possibly invalid or comma-ok) value or type - xlist = []*operand{&x} - - default: - // multiple (possibly invalid) values or types - xlist = make([]*operand, len(elist)) - ntypes := 0 - for i, e := range elist { - var x operand - check.exprOrType(&x, e) - xlist[i] = &x - switch x.mode { - case invalid: - ntypes = len(xlist) // make 'if' condition fail below (no additional error in this case) - case typexpr: - ntypes++ - check.instantiatedOperand(&x) - } - } - if 0 < ntypes && ntypes < len(xlist) { - check.error(xlist[0], "mix of value and type expressions") - ok = false - } - } - - return -} - func (check *Checker) exprList(elist []syntax.Expr, allowCommaOk bool) (xlist []*operand, commaOk bool) { switch len(elist) { case 0: |