]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: respect commaerr in Checker.exprList
authorRobert Griesemer <gri@golang.org>
Tue, 21 Mar 2023 20:59:24 +0000 (13:59 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 21 Mar 2023 21:25:48 +0000 (21:25 +0000)
The changes to exprList (in call.go), made in CL 282193, didn't
get faithfully ported to types2: in the case of operand mode
commaerr, unpacking didn't correctly set the type of the 2nd
value to error. This shouldn't matter for the compiler, but
the code differs from the go/types version. Make them the same.

Change-Id: I6f69575f9ad4f43169b851dffeed85c19588a261
Reviewed-on: https://go-review.googlesource.com/c/go/+/478255
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

src/cmd/compile/internal/types2/call.go

index 3f5c12599ac8cd2a99f1d5faa5a06a761bdb5331..db83d58fcce61a885d0c18882c60f5ed06b5a029 100644 (file)
@@ -283,8 +283,11 @@ func (check *Checker) exprList(elist []syntax.Expr, allowCommaOk bool) (xlist []
                // exactly one (possibly invalid or comma-ok) value
                xlist = []*operand{&x}
                if allowCommaOk && (x.mode == mapindex || x.mode == commaok || x.mode == commaerr) {
-                       x.mode = value
-                       xlist = append(xlist, &operand{mode: value, expr: e, typ: Typ[UntypedBool]})
+                       x2 := &operand{mode: value, expr: e, typ: Typ[UntypedBool]}
+                       if x.mode == commaerr {
+                               x2.typ = universeError
+                       }
+                       xlist = append(xlist, x2)
                        commaOk = true
                }