aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-01-25 18:07:41 -0800
committerBruce Hill <bitbucket@bruce-hill.com>2018-01-25 18:07:51 -0800
commitfb22ba11ac2c363941d8bf34f8b8a9181bd7c7dc (patch)
tree1939c69ef3c9c43b473ce9e8ca1f7045d57faa09
parent6668918b2e8a5548bb66864c5051ca94c61994d3 (diff)
Fixed improperly handling locals of a block.
-rw-r--r--nomsu.lua5
-rwxr-xr-xnomsu.moon4
2 files changed, 5 insertions, 4 deletions
diff --git a/nomsu.lua b/nomsu.lua
index 5689426..f1d6e5b 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -897,14 +897,15 @@ do
local lua = self:tree_to_lua(arg)
if #tree.value == 1 and lua.expr and not lua.statements then
return {
- expr = lua.expr
+ expr = lua.expr,
+ locals = lua.locals
}
end
if lua.locals then
local _list_1 = lua.locals
for _index_1 = 1, #_list_1 do
local l = _list_1[_index_1]
- locals[l] = true
+ table.insert(locals, l)
end
end
if lua.statements then
diff --git a/nomsu.moon b/nomsu.moon
index 52ce1ea..294a86f 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -642,9 +642,9 @@ class NomsuCompiler
for arg in *tree.value
lua = @tree_to_lua arg
if #tree.value == 1 and lua.expr and not lua.statements
- return expr:lua.expr
+ return {expr:lua.expr, locals:lua.locals}
if lua.locals
- for l in *lua.locals do locals[l] = true
+ for l in *lua.locals do table.insert(locals, l)
if lua.statements then insert lua_bits, lua.statements
elseif lua.expr then insert lua_bits, "#{lua.expr};"
utils.deduplicate(locals)