From b1ecc7defc6cdac3cf6e75632625944977f02d7e Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Sat, 28 Feb 2015 11:22:24 -0800 Subject: [PATCH] fix get root block for root block --- moonscript/cmd/lint.lua | 11 ++++------- moonscript/cmd/lint.moon | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/moonscript/cmd/lint.lua b/moonscript/cmd/lint.lua index b0f607d..d4573f7 100644 --- a/moonscript/cmd/lint.lua +++ b/moonscript/cmd/lint.lua @@ -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({ diff --git a/moonscript/cmd/lint.moon b/moonscript/cmd/lint.moon index 361f15f..922e04f 100644 --- a/moonscript/cmd/lint.moon +++ b/moonscript/cmd/lint.moon @@ -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