diff --git a/moonscript/transform/statement.lua b/moonscript/transform/statement.lua index 6c8a60bf..47dd0de7 100644 --- a/moonscript/transform/statement.lua +++ b/moonscript/transform/statement.lua @@ -204,7 +204,13 @@ return Transformer({ local _continue_0 = false repeat local name = names[_index_0] - if not (name[2]:match("^%u")) then + local str_name + if ntype(name) == "ref" then + str_name = name[2] + else + str_name = name + end + if not (str_name:match("^%u")) then _continue_0 = true break end diff --git a/moonscript/transform/statement.moon b/moonscript/transform/statement.moon index 2d3a3455..42c3ec79 100644 --- a/moonscript/transform/statement.moon +++ b/moonscript/transform/statement.moon @@ -122,7 +122,12 @@ Transformer { if node[2] == "^" names = for name in *names - continue unless name[2]\match "^%u" + str_name = if ntype(name) == "ref" + name[2] + else + name + + continue unless str_name\match "^%u" name {"declare", names} diff --git a/spec/inputs/local.moon b/spec/inputs/local.moon index d4a616ca..fec78b18 100644 --- a/spec/inputs/local.moon +++ b/spec/inputs/local.moon @@ -75,6 +75,17 @@ do d = 2323 +do + local ^ + lowercase = 5 + Uppercase = 3 + + class One + Five = 6 + + class Two + class No + do local * -- this generates a nil value in the body diff --git a/spec/outputs/local.lua b/spec/outputs/local.lua index db19697a..3ee8623e 100644 --- a/spec/outputs/local.lua +++ b/spec/outputs/local.lua @@ -70,6 +70,73 @@ do d = 200 d = 2323 end +do + local Uppercase, One, Two + local lowercase = 5 + Uppercase = 3 + do + local _class_0 + local Five + local _base_0 = { } + _base_0.__index = _base_0 + _class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "One" + }, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({}, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end + }) + _base_0.__class = _class_0 + local self = _class_0 + Five = 6 + One = _class_0 + end + do + local _class_0 + local No + local _base_0 = { } + _base_0.__index = _base_0 + _class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Two" + }, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({}, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end + }) + _base_0.__class = _class_0 + local self = _class_0 + do + local _class_1 + local _base_1 = { } + _base_1.__index = _base_1 + _class_1 = setmetatable({ + __init = function() end, + __base = _base_1, + __name = "No" + }, { + __index = _base_1, + __call = function(cls, ...) + local _self_0 = setmetatable({}, _base_1) + cls.__init(_self_0, ...) + return _self_0 + end + }) + _base_1.__class = _class_1 + No = _class_1 + end + Two = _class_0 + end +end do local _list_0 = { } for _index_0 = 1, #_list_0 do