aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-12-21 15:13:26 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-12-21 15:13:26 -0500
commit325b367a1342826fe7174ce45cfab92091d4dbb5 (patch)
tree921b306025e495f71f008f9f9a4b1291ce2cdcb3 /types.c
parent478ddad9aaf837005f5401126f8872c0e3058bba (diff)
Support logical binary operators on optionals (promote to booleans)
Diffstat (limited to 'types.c')
-rw-r--r--types.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/types.c b/types.c
index ce5f9df0..2b421b40 100644
--- a/types.c
+++ b/types.c
@@ -358,6 +358,9 @@ PUREFUNC bool can_promote(type_t *actual, type_t *needed)
return true;
if (actual->tag == OptionalType) {
+ if (needed->tag == BoolType)
+ return true;
+
// Ambiguous `none` to concrete optional
if (Match(actual, OptionalType)->type == NULL)
return (needed->tag == OptionalType);