aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-12-12 14:01:48 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-12-12 14:01:48 -0500
commitc5db5fef62fb6cc24655bd8f271da313bd16b9a1 (patch)
tree2a977d24189d882456a3da6593310030763aadcb /types.c
parentff95aa5e6442c76a229bb54758617bd278d4f709 (diff)
Fix optional promotion issue
Diffstat (limited to 'types.c')
-rw-r--r--types.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/types.c b/types.c
index 966698ad..f526af60 100644
--- a/types.c
+++ b/types.c
@@ -365,12 +365,12 @@ PUREFUNC bool can_promote(type_t *actual, type_t *needed)
// Optional num -> num
if (needed->tag == NumType && actual->tag == OptionalType && Match(actual, OptionalType)->type->tag == NumType)
return can_promote(Match(actual, OptionalType)->type, needed);
-
- // Optional promotion:
- if (needed->tag == OptionalType && Match(needed, OptionalType)->type != NULL && can_promote(actual, Match(needed, OptionalType)->type))
- return true;
}
+ // Optional promotion:
+ if (needed->tag == OptionalType && Match(needed, OptionalType)->type != NULL && can_promote(actual, Match(needed, OptionalType)->type))
+ return true;
+
if (needed->tag == PointerType && actual->tag == PointerType) {
auto needed_ptr = Match(needed, PointerType);
auto actual_ptr = Match(actual, PointerType);