local * doesn't grab names in nested scopes

This commit is contained in:
leaf corcoran 2013-01-13 12:23:49 -08:00
parent cad4aea610
commit e075c2f971
6 changed files with 41 additions and 2 deletions

View File

@ -336,6 +336,9 @@ do
get = function(self, name) get = function(self, name)
return self._state[name] return self._state[name]
end, end,
get_current = function(self, name)
return rawget(self._state, name)
end,
listen = function(self, name, fn) listen = function(self, name, fn)
self._listeners[name] = fn self._listeners[name] = fn
end, end,

View File

@ -196,6 +196,9 @@ class Block
get: (name) => get: (name) =>
@_state[name] @_state[name]
get_current: (name) =>
rawget @_state, name
listen: (name, fn) => listen: (name, fn) =>
@_listeners[name] = fn @_listeners[name] = fn

View File

@ -345,7 +345,7 @@ local Statement = Transformer({
assign = function(self, node) assign = function(self, node)
local names, values = unpack(node, 2) local names, values = unpack(node, 2)
do do
local globber = self:get("name_glob") local globber = self:get_current("name_glob")
if globber then if globber then
local _list_0 = names local _list_0 = names
for _index_0 = 1, #_list_0 do for _index_0 = 1, #_list_0 do

View File

@ -164,7 +164,7 @@ Statement = Transformer {
assign: (node) => assign: (node) =>
names, values = unpack node, 2 names, values = unpack node, 2
if globber = @get "name_glob" if globber = @get_current "name_glob"
for name in *names for name in *names
if globber name if globber name
@put_name name @put_name name

View File

@ -33,3 +33,20 @@ do
local * local *
x,y = "a", "b" x,y = "a", "b"
do
local *
if something
x = 2323
-- this is broken
do
local *
do
x = "one"
x = 100
do
x = "two"

View File

@ -31,3 +31,19 @@ do
local x, y local x, y
x, y = "a", "b" x, y = "a", "b"
end end
do
if something then
x = 2323
end
end
do
local x
do
x = "one"
end
x = 100
do
x = "two"
end
end