diff options
| author | hachem <im@hachem.wtf> | 2026-09-19 14:49:36 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-19 14:49:36 +0200 |
| commit | e5cc80fb6a608aa1fbd0d6fabd1cf614a0fc004a (patch) | |
| tree | bf28325d56488de0cfe8cf4634b6307e229ea437 /eval.c | |
| parent | b79902cd36b2c5b54bbf0f07078fc528754977b2 (diff) | |
fix: add a workaround for redeclaration
Diffstat (limited to 'eval.c')
| -rw-r--r-- | eval.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -222,6 +222,19 @@ static enum RunStatus declare(struct Machine* machine, const struct Node* node) return RUN_DONE; } +static enum RunStatus undeclare(struct Machine* machine, const struct Node* node) +{ + struct Variable* variable = find_variable(machine, node->name); + if (variable == NULL) + { + (void)complain(node, "cannot undeclare what was never declared"); + return RUN_FAILED; + } + + variable->declared = false; + return RUN_DONE; +} + static enum RunStatus emit(struct Machine* machine, const struct Node* node) { struct Type type; @@ -261,6 +274,7 @@ static enum RunStatus execute_one(struct Machine* machine, const struct Node* no switch (node->kind) { case STMT_DECLARE: return declare(machine, node); + case STMT_UNDECLARE: return undeclare(machine, node); case STMT_EMIT: return emit(machine, node); case STMT_STATIC_ASSERT: return static_assert_statement(machine, node); default: break; |
