Hello,
I must be clumsy in some way, but I have questions about the cases below.
Both type‑checks:
fn test {x:int} (x:int(x)): bool(x <= 0) = (x <= 0) /* Case 1.a */
fn test {x:int} (x:int(x)): bool(0 <= x) = (0 <= x) /* Case 1.b */
This one don’t for a reason which is mysterious to me, unless it’s related
to the case after:
fn test {x:int} (x:int(x)): bool(x <= 0 && 0 <= x) = (x <= 0 && 0 <=
x) /* Case 2 */
This is in fact equivalent to this, which fails too, for a reason looking
more obvious to me:
fn test {x:int} (x:int(x)): bool(x == 0) = (x == 0) /* Case 3 */
In case #3, 0
is not of the type int(x)
, unless x
is zero, which is
not always the case. However, if I do the following, I still get an error:
fn test {x:int|x==0} (x:int(x)): bool(x == 0) = (x == 0) /* Case 4 */
I feel to understand why case #3 fails (while not sure I really understand
the reason), but not why case #4 fails too.
I also wonder if ATS is turning case #2 into case #3.