mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
mark position of table self assigns to not confuse linter
This commit is contained in:
parent
2d5dd107d4
commit
09a2a5c545
@ -167,7 +167,7 @@ do
|
||||
local sc = self.statement_compilers
|
||||
self.statement_compilers = setmetatable({
|
||||
assign = function(block, node)
|
||||
local _, names, values = unpack(node)
|
||||
local names = node[2]
|
||||
for _index_0 = 1, #names do
|
||||
local _continue_0 = false
|
||||
repeat
|
||||
|
@ -76,7 +76,7 @@ class LinterBlock extends Block
|
||||
sc = @statement_compilers
|
||||
@statement_compilers = setmetatable {
|
||||
assign: (block, node) ->
|
||||
_, names, values = unpack node
|
||||
names = node[2]
|
||||
-- extract the names to be declared
|
||||
for name in *names
|
||||
-- don't include autogenerated names
|
||||
|
@ -277,8 +277,8 @@ local function check_lua_string(str, pos, right, left)
|
||||
end
|
||||
|
||||
-- :name in table literal
|
||||
local function self_assign(name)
|
||||
return {{"key_literal", name}, name}
|
||||
local function self_assign(name, pos)
|
||||
return {{"key_literal", name}, {"ref", name, [-1] = pos}}
|
||||
end
|
||||
|
||||
local err_msg = "Failed to parse:%s\n [%d] >> %s"
|
||||
@ -552,7 +552,7 @@ local build_grammar = wrap_env(function()
|
||||
op"*" + op"^" +
|
||||
Ct(NameList) * (sym"=" * Ct(ExpListLow))^-1) / mark"export",
|
||||
|
||||
KeyValue = (sym":" * -SomeSpace * Name) / self_assign + Ct((KeyName + sym"[" * Exp * sym"]" + DoubleString + SingleString) * symx":" * (Exp + TableBlock)),
|
||||
KeyValue = (sym":" * -SomeSpace * Name * lpeg.Cp()) / self_assign + Ct((KeyName + sym"[" * Exp * sym"]" + DoubleString + SingleString) * symx":" * (Exp + TableBlock)),
|
||||
KeyValueList = KeyValue * (sym"," * KeyValue)^0,
|
||||
KeyValueLine = CheckIndent * KeyValueList * sym","^-1,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user