Closed anton-trunov closed 1 month ago
First we check whether X? is null and return false in this case because null cannot be equal to X
In general, equality comparisons only make sense for terms of the same type. The check you describe should be done by the user, e.g. if (x != null) { return x!! == y }
where, for instance, x: Int?
and y: Int
.
Same for comparison of X? and X?: First we check if either both of these are null or both of these are not null and compare them accordingly, and in other cases (first is null and second is not or vice versa) we just return false
Look at the tests: we don't forbid equality comparisons for X?
and X?
in general, just for non-equality types like Builder
or structs.
Why do we forbid comparing X and X?? It makes sense to allow comparing these two
wait, we don't actually forbid that -- we check assignability of types
so, my example above is not correct, because Int
and Int?
are both equality types
@Gusarich Added a test for that: https://github.com/tact-lang/tact/pull/650/files#diff-570728cab178f5e1fa5f1885b32ee9826e95de3a357d341adbc331578591ab1a
Closes #649