Fix var type inference2

Giving it another try.
@dwightguth please re-review.
Ok... I think I've addressed all of your comments, except for this one.
Previously, we wanted to set the sort of the rewrite as LUB of left and right, but we decided to change the way we disambiguate overloaded operators, by selecting the biggest sort possible in that context. Also, if the rewrite involves a function, then the sort is given by the left hand side (of course, if possible in the context).

I think I've done that. The funny thing is, all the examples still pass, so it seems it doesn't matter what the sort of the rewrite is, as long as it passes the type checking.
My proposal is to delay solving this inconsistency until we run into problems, and we have a better understanding of what we want.