aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-02 22:34:35 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-11-02 22:34:35 -0400
commit92a593b80fe935eb21615dc45b4d7868b254bec6 (patch)
tree029e43ff46abc4bd86000c5a90900511ea99fcf3 /typecheck.c
parent0b7a0dd043a4c7ccfc924d618508d1edc0115e2f (diff)
Support reductions for comparison operators like == and <
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/typecheck.c b/typecheck.c
index bc3c7982..bff7d080 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -1033,6 +1033,12 @@ type_t *get_type(env_t *env, ast_t *ast)
auto reduction = Match(ast, Reduction);
type_t *iter_t = get_type(env, reduction->iter);
+ if (reduction->combination && reduction->combination->tag == BinaryOp) {
+ binop_e op = Match(reduction->combination, BinaryOp)->op;
+ if (op == BINOP_EQ || op == BINOP_NE || op == BINOP_LT || op == BINOP_LE || op == BINOP_GT || op == BINOP_GE)
+ return Type(OptionalType, .type=Type(BoolType));
+ }
+
type_t *value_t;
type_t *iter_value_t = value_type(iter_t);
switch (iter_value_t->tag) {