diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-02 22:34:35 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-02 22:34:35 -0400 |
| commit | 92a593b80fe935eb21615dc45b4d7868b254bec6 (patch) | |
| tree | 029e43ff46abc4bd86000c5a90900511ea99fcf3 /typecheck.c | |
| parent | 0b7a0dd043a4c7ccfc924d618508d1edc0115e2f (diff) | |
Support reductions for comparison operators like == and <
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 6 |
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) { |
