mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
fix lint, mark pos of all refs
This commit is contained in:
parent
da0109bd14
commit
53cf5dd649
@ -62,6 +62,7 @@ do
|
||||
block = function(self, ...)
|
||||
do
|
||||
local _with_0 = _parent_0.block(self, ...)
|
||||
_with_0.block = self.block
|
||||
_with_0.value_compilers = self.value_compilers
|
||||
return _with_0
|
||||
end
|
||||
@ -80,14 +81,13 @@ do
|
||||
self.value_compilers = setmetatable({
|
||||
ref = function(block, val)
|
||||
local name = val[2]
|
||||
if not (block:has_name(name) or whitelist_globals[name]) then
|
||||
local stm = block.current_stms[block.current_stm_i]
|
||||
if not (block:has_name(name) or whitelist_globals[name] or name:match("%.")) then
|
||||
insert(self.lint_errors, {
|
||||
"accessing global " .. tostring(name),
|
||||
stm[-1]
|
||||
val[-1]
|
||||
})
|
||||
end
|
||||
return vc.raw_value(block, val)
|
||||
return vc.ref(block, val)
|
||||
end
|
||||
}, {
|
||||
__index = vc
|
||||
|
@ -56,18 +56,18 @@ class LinterBlock extends Block
|
||||
@value_compilers = setmetatable {
|
||||
ref: (block, val) ->
|
||||
name = val[2]
|
||||
unless block\has_name(name) or whitelist_globals[name]
|
||||
stm = block.current_stms[block.current_stm_i]
|
||||
unless block\has_name(name) or whitelist_globals[name] or name\match "%."
|
||||
insert @lint_errors, {
|
||||
"accessing global #{name}"
|
||||
stm[-1]
|
||||
val[-1]
|
||||
}
|
||||
|
||||
vc.raw_value block, val
|
||||
vc.ref block, val
|
||||
}, __index: vc
|
||||
|
||||
block: (...) =>
|
||||
with super ...
|
||||
.block = @block
|
||||
.value_compilers = @value_compilers
|
||||
|
||||
format_lint = (errors, code, header) ->
|
||||
|
@ -511,7 +511,7 @@ local build_grammar = wrap_env(function()
|
||||
LuaStringOpen = sym"[" * P"="^0 * "[" / trim,
|
||||
LuaStringClose = "]" * P"="^0 * "]",
|
||||
|
||||
Callable = Name / mark"ref" + SelfName + VarArg + Parens / mark"parens",
|
||||
Callable = pos(Name / mark"ref") + SelfName + VarArg + Parens / mark"parens",
|
||||
Parens = sym"(" * Exp * sym")",
|
||||
|
||||
FnArgs = symx"(" * Ct(ExpList^-1) * sym")" + sym"!" * -P"=" * Ct"",
|
||||
|
Loading…
Reference in New Issue
Block a user