mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Improve variable redefinition error
This commit is contained in:
parent
eb3a1d3f2c
commit
b60f53df01
2 changed files with 9 additions and 3 deletions
|
|
@ -288,7 +288,13 @@ local function parse_line(line, state, namespace)
|
|||
if not exp then return nil, ("expected \"= expression\" after %q in definition line; at %s"):format(rem, line.source) end
|
||||
-- define identifier
|
||||
if state.functions[fqm] then return nil, ("trying to define variable %q, but a function with the same name exists; at %s"):format(fqm, line.source) end
|
||||
if state.variables[fqm] then return nil, ("trying to define variable %q but it is already defined; at %s"):format(fqm, line.source) end
|
||||
if state.variables[fqm] then
|
||||
if state.variables[fqm].type == "pending definition" then
|
||||
return nil, ("trying to define variable %q but it is already defined at %s; at %s"):format(fqm, state.variables[fqm].value.source, line.source)
|
||||
else
|
||||
return nil, ("trying to define variable %q but it is already defined; at %s"):format(fqm, line.source)
|
||||
end
|
||||
end
|
||||
r.fqm = fqm
|
||||
r.expression = exp
|
||||
state.variables[fqm] = { type = "pending definition", value = { expression = nil, source = r.source } }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue