Skip to content

Commit

Permalink
marking a variable as assigned only if it was declared
Browse files Browse the repository at this point in the history
  • Loading branch information
andremm authored and mascarenhas committed Nov 3, 2017
1 parent 5406e54 commit cdc2cc9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions titan-compiler/checker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ function checkstat(node, st, errors)
st:with_block(checkfor, node, st, errors)
elseif tag == "Stat_Assign" then
checkexp(node.var, st, errors)
-- mark this variable as assigned to
if node.var._tag == "Var_Name" then
node.var._decl._assigned = true
-- mark this declared variable as assigned to
if node.var._tag == "Var_Name" and node.var._decl then
node.var._decl._assigned = true
end
checkexp(node.exp, st, errors, node.var._type)
node.exp = trycoerce(node.exp, node.var._type)
Expand Down

0 comments on commit cdc2cc9

Please sign in to comment.