]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: don't override x.mode before using it
authorRobert Griesemer <gri@golang.org>
Fri, 20 Aug 2021 04:35:57 +0000 (21:35 -0700)
committerRobert Griesemer <gri@golang.org>
Sat, 21 Aug 2021 00:55:22 +0000 (00:55 +0000)
Changing the mode of x before using the old value is clearly wrong.
And x is not needed anymore afterward so besides being misplaced,
the assignment is not needed in the first place.

Tested manually as it's a bit complicated to set up a test.

Needs to be back-ported to 1.17.

Fixes #47777.

Change-Id: I06f1fa9443eb98009b4276f566d557fd52f1d6d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/343809
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/go/types/call.go

index 390e9cd892fc368338e063be6633621cade40496..08ef2451bf397681af478d2d62e7bbff64f34487 100644 (file)
@@ -223,7 +223,6 @@ func (check *Checker) exprList(elist []ast.Expr, allowCommaOk bool) (xlist []*op
                // 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
                        x2 := &operand{mode: value, expr: e, typ: Typ[UntypedBool]}
                        if x.mode == commaerr {
                                x2.typ = universeError