Commit 30673769 authored by Kunpei Sakai's avatar Kunpei Sakai Committed by Matthew Dempsky

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/97035Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 0c471dfa
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment