Closed CohenArthur closed 1 week ago
One issue is that this code does work, when it should not:
type Nothing;
type NullableInt = 15 | Nothing;
func g(n: NullableInt) {}
where x = 16;
g(15);
g(x);
g(Nothing);
and replacing NullableInt
's definition with a proper one (int | Nothing
) causes the code to no longer work :upside_down_face:
Getting closer. Another testcase we must handle before merging this:
type unit;
type bool;
type char;
type int;
type float;
type string;
func fifteen(inner: int) {}
where x = fifteen(14);
where y = fifteen(14 * 12);
ext func magic() -> int;
type Nothing;
type NullableInt = int | Nothing;
func g(n: NullableInt) {}
g(magic());
One other issue is that we show type errors with the flattened version of the type, so for example it'll show as "expected 15 | 16, got string"
There is an issue when formatting empty typesets, for example the char
type if there are no characters in the program. this will be fixed once we address the formatting issues
the only blocker now is the handling of builtin types for arithmetic operations
The issue with arithmetic builtins lie in the expected_arithmetic_types
function, where we need to do something a little smarter than recreate our union types.
Fixes #674