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>
// 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.