diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 16:03:38 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 16:03:38 -0500 |
| commit | b04a1b30903636bf97a8e04efe88e8a177855bcb (patch) | |
| tree | d85a765c07c3cc686485d30ef7a4216f4d830cad /typecheck.c | |
| parent | 42da91936e50ab652d140677689b519fe9deb3fe (diff) | |
Implement lambdas and closures
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/typecheck.c b/typecheck.c index 88b9d892..671326d0 100644 --- a/typecheck.c +++ b/typecheck.c @@ -67,7 +67,7 @@ type_t *parse_type_ast(env_t *env, type_ast_t *ast) } } REVERSE_LIST(type_args); - return Type(FunctionType, .args=type_args, .ret=ret_t); + return Type(ClosureType, Type(FunctionType, .args=type_args, .ret=ret_t)); } case UnknownTypeAST: code_err(ast, "I don't know how to get this type"); } @@ -610,7 +610,7 @@ type_t *get_type(env_t *env, ast_t *ast) case Lambda: { auto lambda = Match(ast, Lambda); arg_t *args = NULL; - env_t *scope = fresh_scope(env); + env_t *scope = fresh_scope(env); // For now, just use closed variables in scope normally for (arg_ast_t *arg = lambda->args; arg; arg = arg->next) { type_t *t = arg->type ? parse_type_ast(env, arg->type) : get_type(env, arg->value); args = new(arg_t, .name=arg->name, .type=t, .next=args); |
