aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-02 20:22:19 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-11-02 20:22:19 -0400
commit0b7a0dd043a4c7ccfc924d618508d1edc0115e2f (patch)
tree6e1942840ab7e1e10bed111d8d5a012eacdf8b9b /typecheck.c
parent985011aed89706e9a4b06e6c6f3239d53ac8e6e8 (diff)
Change reducers to use (OP: ...) syntax and return an optional value
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c16
1 files changed, 1 insertions, 15 deletions
diff --git a/typecheck.c b/typecheck.c
index 9818ad33..bc3c7982 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -1054,21 +1054,7 @@ type_t *get_type(env_t *env, ast_t *ast)
default: code_err(reduction->iter, "I don't know how to do a reduction over %T values", iter_t);
}
- env_t *scope = fresh_scope(env);
- set_binding(scope, "$reduction", new(binding_t, .type=value_t));
- set_binding(scope, "$iter_value", new(binding_t, .type=value_t));
- type_t *t = get_type(scope, reduction->combination);
- if (!reduction->fallback)
- return t;
- type_t *fallback_t = get_type(env, reduction->fallback);
- if (fallback_t->tag == AbortType || fallback_t->tag == ReturnType)
- return t;
- else if (can_promote(fallback_t, t))
- return t;
- else if (can_promote(t, fallback_t))
- return fallback_t;
- else
- return NULL;
+ return Type(OptionalType, .type=value_t);
}
case UpdateAssign: