go/types, types2: simplify Checker.exprList

Change-Id: I7e9e5bef9364afc959c66d9765180c4ed967f517
Reviewed-on: https://go-review.googlesource.com/c/go/+/478755
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2023-03-22 20:01:17 -07:00 committed by Gopher Robot
parent a933d06271
commit 1742691270
6 changed files with 10 additions and 10 deletions

View File

@ -361,7 +361,7 @@ func (check *Checker) initVars(lhs []*Var, orig_rhs []syntax.Expr, returnStmt sy
// resulting in 2 or more values; otherwise we have an assignment mismatch.
if r != 1 {
if returnStmt != nil {
rhs, _ := check.exprList(orig_rhs, false)
rhs := check.exprList(orig_rhs)
check.returnError(returnStmt, lhs, rhs)
} else {
check.assignError(orig_rhs, l, r)

View File

@ -45,7 +45,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
switch id {
default:
// make argument getter
xlist, _ := check.exprList(call.ArgList, false)
xlist := check.exprList(call.ArgList)
arg = func(x *operand, i int) { *x = *xlist[i] }
nargs = len(xlist)
// evaluate first argument, if present

View File

@ -226,7 +226,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
}
// evaluate arguments
args, _ := check.exprList(call.ArgList, false)
args := check.exprList(call.ArgList)
sig = check.arguments(call, sig, targs, args, xlist)
if wasGeneric && sig.TypeParams().Len() == 0 {
@ -261,12 +261,12 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
return statement
}
func (check *Checker) exprList(elist []syntax.Expr, allowCommaOk bool) (xlist []*operand, commaOk bool) {
func (check *Checker) exprList(elist []syntax.Expr) (xlist []*operand) {
switch len(elist) {
case 0:
// nothing to do
case 1:
return check.multiExpr(elist[0], allowCommaOk)
xlist, _ = check.multiExpr(elist[0], false)
default:
// multiple (possibly invalid) values
xlist = make([]*operand, len(elist))

View File

@ -359,7 +359,7 @@ func (check *Checker) initVars(lhs []*Var, orig_rhs []ast.Expr, returnStmt ast.S
// resulting in 2 or more values; otherwise we have an assignment mismatch.
if r != 1 {
if returnStmt != nil {
rhs, _ := check.exprList(orig_rhs, false)
rhs := check.exprList(orig_rhs)
check.returnError(returnStmt, lhs, rhs)
} else {
check.assignError(orig_rhs, l, r)

View File

@ -46,7 +46,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
switch id {
default:
// make argument getter
xlist, _ := check.exprList(call.Args, false)
xlist := check.exprList(call.Args)
arg = func(x *operand, i int) { *x = *xlist[i] }
nargs = len(xlist)
// evaluate first argument, if present

View File

@ -228,7 +228,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
}
// evaluate arguments
args, _ := check.exprList(call.Args, false)
args := check.exprList(call.Args)
sig = check.arguments(call, sig, targs, args, xlist)
if wasGeneric && sig.TypeParams().Len() == 0 {
@ -263,12 +263,12 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
return statement
}
func (check *Checker) exprList(elist []ast.Expr, allowCommaOk bool) (xlist []*operand, commaOk bool) {
func (check *Checker) exprList(elist []ast.Expr) (xlist []*operand) {
switch len(elist) {
case 0:
// nothing to do
case 1:
return check.multiExpr(elist[0], allowCommaOk)
xlist, _ = check.multiExpr(elist[0], false)
default:
// multiple (possibly invalid) values
xlist = make([]*operand, len(elist))