Surprising evaluation order

As far as I know this expands to

a = tree.left
b = tree.left.right
c = tree
tree = a
tree.left = b
tree.left.right = c

which doesn’t match your rotateright1. I don’t know what evaluation order you expected but

    tree.left.right, tree.left, tree =
        tree, tree.left.right, tree.left

should be a better match to rotateright1.

To see what evaluation order Julia actually uses you can do

@code_lowered rotateright2(tree)
2 Likes