mirror of
https://github.com/leafo/moonscript.git
synced 2024-10-05 05:34:19 +00:00
local * doesn't grab names in nested scopes
This commit is contained in:
parent
cad4aea610
commit
e075c2f971
@ -336,6 +336,9 @@ do
|
||||
get = function(self, name)
|
||||
return self._state[name]
|
||||
end,
|
||||
get_current = function(self, name)
|
||||
return rawget(self._state, name)
|
||||
end,
|
||||
listen = function(self, name, fn)
|
||||
self._listeners[name] = fn
|
||||
end,
|
||||
|
@ -196,6 +196,9 @@ class Block
|
||||
get: (name) =>
|
||||
@_state[name]
|
||||
|
||||
get_current: (name) =>
|
||||
rawget @_state, name
|
||||
|
||||
listen: (name, fn) =>
|
||||
@_listeners[name] = fn
|
||||
|
||||
|
@ -345,7 +345,7 @@ local Statement = Transformer({
|
||||
assign = function(self, node)
|
||||
local names, values = unpack(node, 2)
|
||||
do
|
||||
local globber = self:get("name_glob")
|
||||
local globber = self:get_current("name_glob")
|
||||
if globber then
|
||||
local _list_0 = names
|
||||
for _index_0 = 1, #_list_0 do
|
||||
|
@ -164,7 +164,7 @@ Statement = Transformer {
|
||||
assign: (node) =>
|
||||
names, values = unpack node, 2
|
||||
|
||||
if globber = @get "name_glob"
|
||||
if globber = @get_current "name_glob"
|
||||
for name in *names
|
||||
if globber name
|
||||
@put_name name
|
||||
|
@ -33,3 +33,20 @@ do
|
||||
local *
|
||||
x,y = "a", "b"
|
||||
|
||||
|
||||
do
|
||||
local *
|
||||
if something
|
||||
x = 2323
|
||||
|
||||
-- this is broken
|
||||
do
|
||||
local *
|
||||
do
|
||||
x = "one"
|
||||
|
||||
x = 100
|
||||
|
||||
do
|
||||
x = "two"
|
||||
|
||||
|
@ -30,4 +30,20 @@ end
|
||||
do
|
||||
local x, y
|
||||
x, y = "a", "b"
|
||||
end
|
||||
do
|
||||
|
||||
if something then
|
||||
x = 2323
|
||||
end
|
||||
end
|
||||
do
|
||||
local x
|
||||
do
|
||||
x = "one"
|
||||
end
|
||||
x = 100
|
||||
do
|
||||
x = "two"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user