]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix typechecking in finishcompare
authorKunpei Sakai <namusyaka@gmail.com>
Sun, 25 Feb 2018 09:14:20 +0000 (18:14 +0900)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 26 Feb 2018 22:10:51 +0000 (22:10 +0000)
Previously, finishcompare just used SetTypecheck, but this didn't
recursively update any untyped bool typed subexpressions. This CL
changes it to call typecheck, which correctly handles this.

Also cleaned up outdated code for simplifying logic.

Updates #23834

Change-Id: Ic7f92d2a77c2eb74024ee97815205371761c1c90
Reviewed-on: https://go-review.googlesource.com/97035
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/walk.go

index b0614219e600f796395be123262f9a8ea62f8dfb..02d216ab625d3c755ecb1e7e3e1532ebf045321e 100644 (file)
@@ -3452,18 +3452,14 @@ func walkcompare(n *Node, init *Nodes) *Node {
 // The result of finishcompare MUST be assigned back to n, e.g.
 //     n.Left = finishcompare(n.Left, x, r, init)
 func finishcompare(n, r *Node, init *Nodes) *Node {
-       // Use nn here to avoid passing r to typecheck.
-       nn := r
-       nn = typecheck(nn, Erv)
-       nn = walkexpr(nn, init)
-       r = nn
+       r = typecheck(r, Erv)
+       r = walkexpr(r, init)
        if r.Type != n.Type {
                r = nod(OCONVNOP, r, nil)
                r.Type = n.Type
-               r.SetTypecheck(1)
-               nn = r
+               r = typecheck(r, Erv)
        }
-       return nn
+       return r
 }
 
 // isIntOrdering reports whether n is a <, ≤, >, or ≥ ordering between integers.