Make setq bind locally

This commit is contained in:
2022-11-16 22:55:25 -05:00
parent a093fb0b9c
commit 2ae4e38400
2 changed files with 7 additions and 3 deletions

View File

@@ -152,14 +152,14 @@ struct ucl_object *ucl_special_while(struct ucl_scope *scope, struct ucl_object
struct ucl_object *ucl_special_setq(struct ucl_scope *scope, struct ucl_object *args) {
// TODO: Check arguments
struct ucl_object *sym = ucl_car(args);
struct ucl_scope *root_scope = ucl_scope_get_root(scope);
if (sym->type != UCL_TYPE_SYMBOL) {
return ucl_error_create("First argument to setq must be a symbol");
}
struct ucl_object *value = ucl_evaluate(scope, ucl_list_nth(args, 1));
UCL_RET_IF_ERROR(value);
ucl_scope_put(root_scope, sym->symbol, value);
ucl_scope_put(scope, sym->symbol, value);
return value;
}