Skip to content

Commit 3067376

Browse files
namusyakamdempsky
authored andcommitted
cmd/compile: fix typechecking in finishcompare
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 <[email protected]>
1 parent 0c471df commit 3067376

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/cmd/compile/internal/gc/walk.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,18 +3452,14 @@ func walkcompare(n *Node, init *Nodes) *Node {
34523452
// The result of finishcompare MUST be assigned back to n, e.g.
34533453
// n.Left = finishcompare(n.Left, x, r, init)
34543454
func finishcompare(n, r *Node, init *Nodes) *Node {
3455-
// Use nn here to avoid passing r to typecheck.
3456-
nn := r
3457-
nn = typecheck(nn, Erv)
3458-
nn = walkexpr(nn, init)
3459-
r = nn
3455+
r = typecheck(r, Erv)
3456+
r = walkexpr(r, init)
34603457
if r.Type != n.Type {
34613458
r = nod(OCONVNOP, r, nil)
34623459
r.Type = n.Type
3463-
r.SetTypecheck(1)
3464-
nn = r
3460+
r = typecheck(r, Erv)
34653461
}
3466-
return nn
3462+
return r
34673463
}
34683464

34693465
// isIntOrdering reports whether n is a <, ≤, >, or ≥ ordering between integers.

0 commit comments

Comments
 (0)