correct escape new chain format for lua keywords

This commit is contained in:
leaf corcoran 2015-10-05 20:53:54 -07:00
parent c4ad47c112
commit 24b3a86c68
6 changed files with 19 additions and 5 deletions

View File

@ -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")

View File

@ -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"

View File

@ -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] = {

View File

@ -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]} }

View File

@ -111,3 +111,8 @@ do
with hi
return .a, .b
do
with dad
.if "yes"
y = .end.of.function

View File

@ -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