Bugfix for if var := value
syntax inside a lambda
This commit is contained in:
parent
d803502032
commit
88ab24c133
@ -332,10 +332,10 @@ static void add_closed_vars(Table_t *closed_vars, env_t *enclosing_scope, env_t
|
|||||||
case If: {
|
case If: {
|
||||||
auto if_ = Match(ast, If);
|
auto if_ = Match(ast, If);
|
||||||
ast_t *condition = if_->condition;
|
ast_t *condition = if_->condition;
|
||||||
add_closed_vars(closed_vars, enclosing_scope, env, condition);
|
|
||||||
if (condition->tag == Declare) {
|
if (condition->tag == Declare) {
|
||||||
env_t *truthy_scope = fresh_scope(env);
|
env_t *truthy_scope = fresh_scope(env);
|
||||||
bind_statement(truthy_scope, condition);
|
bind_statement(truthy_scope, condition);
|
||||||
|
add_closed_vars(closed_vars, enclosing_scope, env, Match(condition, Declare)->value);
|
||||||
ast_t *var = Match(condition, Declare)->var;
|
ast_t *var = Match(condition, Declare)->var;
|
||||||
type_t *cond_t = get_type(truthy_scope, var);
|
type_t *cond_t = get_type(truthy_scope, var);
|
||||||
if (cond_t->tag == OptionalType) {
|
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, truthy_scope, if_->body);
|
||||||
add_closed_vars(closed_vars, enclosing_scope, env, if_->else_body);
|
add_closed_vars(closed_vars, enclosing_scope, env, if_->else_body);
|
||||||
} else {
|
} else {
|
||||||
|
add_closed_vars(closed_vars, enclosing_scope, env, condition);
|
||||||
env_t *truthy_scope = env;
|
env_t *truthy_scope = env;
|
||||||
type_t *cond_t = get_type(env, condition);
|
type_t *cond_t = get_type(env, condition);
|
||||||
if (condition->tag == Var && cond_t->tag == OptionalType) {
|
if (condition->tag == Var && cond_t->tag == OptionalType) {
|
||||||
|
Loading…
Reference in New Issue
Block a user