Closed seizethedave closed 7 years ago
There's been a longstanding problem where the ternary operator e ? x : y
does not typecheck if the types of x
and y
are not exactly equal. The correct behavior is for the whole ternary expression to have the "least upper bound" of the two types. So for instance, if x
is a bag and y
is a set, then the whole thing should be a bag.
The commit I made fixes this exact case, but at some point we'll need to document Cozy's type hierarchy and fully implement the least-upper-bound function.
here's a spec:
and the output:
(Commenting out the 'if' statement fixes it.)