feat: add error message for variable redefenition attempt

This commit is contained in:
samsonium
2026-10-21 04:42:58 +03:00
parent 4a366cb0ac
commit 73a2a50a0b
+18 -3
View File
@@ -1056,9 +1056,19 @@ fzl_walk_res_t walk(fzl_walker_t *walker, fzl_node_t *node)
if (res != FZL_SYMTABLE_RESULT_OK)
{
fzl_token_t *tok = node->var.identifier->token;
snprintf(wlast_err, sizeof(wlast_err),
"'%s': cannot store '%s' at %ld:%ld", tok->filename,
(char *)tok->value, tok->ln, tok->cn);
if (res == FZL_SYMTABLE_RESULT_EXISTS)
{
snprintf(wlast_err, sizeof(wlast_err),
"'%s': cannot redefine '%s' at %ld:%ld", tok->filename,
(char *)tok->value, tok->ln, tok->cn);
}
else
{
snprintf(wlast_err, sizeof(wlast_err),
"'%s': cannot store '%s' at %ld:%ld", tok->filename,
(char *)tok->value, tok->ln, tok->cn);
}
return (fzl_walk_res_t){.error = true, .error_msg = wlast_err};
}
@@ -1225,6 +1235,11 @@ int fzl_walk(fzl_walker_t *walker)
push_op(walker, FZL_OPCODE_RM_ENVTABLE);
fin_ctx(walker);
if (walker->ctx)
{
while (walker->ctx)
fin_ctx(walker);
}
if (result.error && !wlast_err[0])
snprintf(wlast_err, sizeof(wlast_err), "%s", result.error_msg);