Fix up some tests and type_or_type

This commit is contained in:
Bruce Hill 2025-04-05 01:43:20 -04:00
parent 00fd2b9e67
commit cb6a5f264c
3 changed files with 10 additions and 4 deletions

View File

@ -153,6 +153,12 @@ type_t *type_or_type(type_t *a, type_t *b)
return a->tag == OptionalType ? a : Type(OptionalType, a);
if (a->tag == ReturnType && b->tag == ReturnType)
return Type(ReturnType, .ret=type_or_type(Match(a, ReturnType)->ret, Match(b, ReturnType)->ret));
if (is_incomplete_type(a) && type_eq(b, most_complete_type(a, b)))
return b;
if (is_incomplete_type(b) && type_eq(a, most_complete_type(a, b)))
return a;
if (type_is_a(b, a)) return a;
if (type_is_a(a, b)) return b;
if (a->tag == AbortType || a->tag == ReturnType) return non_optional(b);

View File

@ -99,8 +99,8 @@ func main():
>> ints : [{Int=Int}] = [{}, {0=0}, {99=99}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 2=-99, 3=3}, {1=1, 99=-99, 3=4}]:sorted()
= [{}, {0=0}, {1=1, 2=-99, 3=3}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 99=-99, 3=4}, {99=99}]
>> other_ints : [{Int}] = [{}, {1}, {2}, {99}, {0, 3}, {1, 2}, {99}]:sorted()
= [{}, {0, 3}, {1}, {1, 2}, {2}, {99}, {99}]
>> other_ints : [{Int}] = [{/}, {1}, {2}, {99}, {0, 3}, {1, 2}, {99}]:sorted()
= [{/}, {0, 3}, {1}, {1, 2}, {2}, {99}, {99}]
do:
# Default values:

View File

@ -56,7 +56,7 @@ func main():
= [65, 109, 233, 108, 105, 101]
>> amelie:bytes()
= [0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65]
>> Text.from_bytes([0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65])!
>> Text.from_bytes([0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65])!
= "Amélie"
>> Text.from_bytes([Byte(0xFF)])
= none
@ -202,7 +202,7 @@ func main():
= ["PENGUIN"]
>> Text.from_codepoint_names(["not a valid name here buddy"])
= none : Text
= none
>> "Hello":replace("ello", "i")
= "Hi"