mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
fix get root block for root block
This commit is contained in:
parent
182969dc81
commit
b1ecc7defc
@ -55,7 +55,7 @@ do
|
||||
local _parent_0 = Block
|
||||
local _base_0 = {
|
||||
lint_check_unused = function(self)
|
||||
if not (self.lint_unused_names) then
|
||||
if not (self.lint_unused_names and next(self.lint_unused_names)) then
|
||||
return
|
||||
end
|
||||
local names_by_position = { }
|
||||
@ -102,13 +102,7 @@ do
|
||||
self:lint_check_unused()
|
||||
return _parent_0.render(self, ...)
|
||||
end,
|
||||
get_root_block = function(self)
|
||||
return self
|
||||
end,
|
||||
block = function(self, ...)
|
||||
self.get_root_block = self.get_root_block or function()
|
||||
return self
|
||||
end
|
||||
do
|
||||
local _with_0 = _parent_0.block(self, ...)
|
||||
_with_0.block = self.block
|
||||
@ -129,6 +123,9 @@ do
|
||||
whitelist_globals = default_whitelist
|
||||
end
|
||||
_parent_0.__init(self, ...)
|
||||
self.get_root_block = function()
|
||||
return self
|
||||
end
|
||||
self.lint_errors = { }
|
||||
local vc = self.value_compilers
|
||||
self.value_compilers = setmetatable({
|
||||
|
@ -55,6 +55,8 @@ default_whitelist = Set {
|
||||
class LinterBlock extends Block
|
||||
new: (whitelist_globals=default_whitelist, ...) =>
|
||||
super ...
|
||||
@get_root_block = -> @
|
||||
|
||||
@lint_errors = {}
|
||||
|
||||
vc = @value_compilers
|
||||
@ -98,7 +100,8 @@ class LinterBlock extends Block
|
||||
|
||||
|
||||
lint_check_unused: =>
|
||||
return unless @lint_unused_names
|
||||
return unless @lint_unused_names and next @lint_unused_names
|
||||
|
||||
names_by_position = {}
|
||||
for name, pos in pairs @lint_unused_names
|
||||
names_by_position[pos] or= {}
|
||||
@ -117,10 +120,7 @@ class LinterBlock extends Block
|
||||
@lint_check_unused!
|
||||
super ...
|
||||
|
||||
get_root_block: => @
|
||||
|
||||
block: (...) =>
|
||||
@get_root_block or= -> @
|
||||
|
||||
with super ...
|
||||
.block = @block
|
||||
|
Loading…
Reference in New Issue
Block a user