mirror of
https://github.com/leafo/moonscript.git
synced 2024-10-05 05:34:19 +00:00
correct escape new chain format for lua keywords
This commit is contained in:
parent
c4ad47c112
commit
24b3a86c68
@ -72,7 +72,7 @@ return {
|
||||
local callee = node[2]
|
||||
local callee_type = ntype(callee)
|
||||
local item_offset = 3
|
||||
if callee_type == "dot" or callee_type == "colon" then
|
||||
if callee_type == "dot" or callee_type == "colon" or callee_type == "index" then
|
||||
callee = self:get("scope_var")
|
||||
if not (callee) then
|
||||
user_error("Short-dot syntax must be called within a with block")
|
||||
|
@ -46,7 +46,7 @@ string_chars = {
|
||||
callee_type = ntype callee
|
||||
item_offset = 3
|
||||
|
||||
if callee_type == "dot" or callee_type == "colon"
|
||||
if callee_type == "dot" or callee_type == "colon" or callee_type == "index"
|
||||
callee = @get "scope_var"
|
||||
unless callee
|
||||
user_error "Short-dot syntax must be called within a with block"
|
||||
|
@ -1492,7 +1492,7 @@ Value = Transformer({
|
||||
})
|
||||
end,
|
||||
chain = function(self, node)
|
||||
for i = 3, #node do
|
||||
for i = 2, #node do
|
||||
local part = node[i]
|
||||
if ntype(part) == "dot" and data.lua_keywords[part[2]] then
|
||||
node[i] = {
|
||||
|
@ -923,7 +923,7 @@ Value = Transformer {
|
||||
-- pull out colon chain
|
||||
chain: (node) =>
|
||||
-- escape lua keywords used in dot accessors
|
||||
for i=3,#node
|
||||
for i=2,#node
|
||||
part = node[i]
|
||||
if ntype(part) == "dot" and data.lua_keywords[part[2]]
|
||||
node[i] = { "index", {"string", '"', part[2]} }
|
||||
|
@ -111,3 +111,8 @@ do
|
||||
with hi
|
||||
return .a, .b
|
||||
|
||||
|
||||
do
|
||||
with dad
|
||||
.if "yes"
|
||||
y = .end.of.function
|
||||
|
@ -154,10 +154,19 @@ do
|
||||
end
|
||||
end
|
||||
do
|
||||
return function()
|
||||
local _
|
||||
_ = function()
|
||||
do
|
||||
local _with_0 = hi
|
||||
return _with_0.a, _with_0.b
|
||||
end
|
||||
end
|
||||
end
|
||||
do
|
||||
do
|
||||
local _with_0 = dad
|
||||
_with_0["if"]("yes")
|
||||
local y = _with_0["end"].of["function"]
|
||||
return _with_0
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user