aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-05 01:43:20 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-05 01:43:20 -0400
commitcb6a5f264c857691cf3db3c9d8e12375e4dc75fd (patch)
tree38f938b4bd9462f21384604c3473841454fe4eef
parent00fd2b9e6705cf80e315c84b35feb6248305770b (diff)
Fix up some tests and type_or_type
-rw-r--r--src/types.c6
-rw-r--r--test/tables.tm4
-rw-r--r--test/text.tm4
3 files changed, 10 insertions, 4 deletions
diff --git a/src/types.c b/src/types.c
index 93326b17..dc330ca9 100644
--- a/src/types.c
+++ b/src/types.c
@@ -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);
diff --git a/test/tables.tm b/test/tables.tm
index 00dc71da..20d76269 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -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:
diff --git a/test/text.tm b/test/text.tm
index 0316a96f..2e061415 100644
--- a/test/text.tm
+++ b/test/text.tm
@@ -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"