WhileyCompiler icon indicating copy to clipboard operation
WhileyCompiler copied to clipboard

FlowTyping over Logical Conditions

Open DavePearce opened this issue 6 years ago • 0 comments

The following now fails to type check:

type Tree is null | Node

type Node is {int data, Tree rhs, Tree lhs}
where (lhs is null) || (lhs.data < data)
where (rhs is null) || (rhs.data > data)

and also in its alternate form:

type Node is {int data, Tree rhs, Tree lhs}
where ((lhs is null) || (lhs.data < data)) && ((rhs is null) || (rhs.data > data))

The problem is that going into the second conjunct, the type of this is {int data, Tree rhs, null lhs}|{int data, Tree rhs, Node lhs}. The current rules for type recombination are not effective here because they do not properly union types.

A simple solution would be to just "reset" the type to its original between clauses.

DavePearce avatar Jul 31 '19 23:07 DavePearce