diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-16 14:20:47 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-16 14:20:47 -0400 |
| commit | 88ab24c1336ef781c3473d122d0fb521cd842390 (patch) | |
| tree | 797f22b7ae1c6f53947c3966291c26bf68bee4bb | |
| parent | d803502032d1d05bb87d3ec18015ea497bad5e32 (diff) | |
Bugfix for `if var := value` syntax inside a lambda
| -rw-r--r-- | compile.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -332,10 +332,10 @@ static void add_closed_vars(Table_t *closed_vars, env_t *enclosing_scope, env_t case If: { auto if_ = Match(ast, If); ast_t *condition = if_->condition; - add_closed_vars(closed_vars, enclosing_scope, env, condition); if (condition->tag == Declare) { env_t *truthy_scope = fresh_scope(env); bind_statement(truthy_scope, condition); + add_closed_vars(closed_vars, enclosing_scope, env, Match(condition, Declare)->value); ast_t *var = Match(condition, Declare)->var; type_t *cond_t = get_type(truthy_scope, var); if (cond_t->tag == OptionalType) { @@ -345,6 +345,7 @@ static void add_closed_vars(Table_t *closed_vars, env_t *enclosing_scope, env_t add_closed_vars(closed_vars, enclosing_scope, truthy_scope, if_->body); add_closed_vars(closed_vars, enclosing_scope, env, if_->else_body); } else { + add_closed_vars(closed_vars, enclosing_scope, env, condition); env_t *truthy_scope = env; type_t *cond_t = get_type(env, condition); if (condition->tag == Var && cond_t->tag == OptionalType) { |
