Skip to content

Commit 0d232f9

Browse files
committed
super tests, fixed regression when compiling chain dot args
1 parent 5c999fb commit 0d232f9

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

moonscript/compile/value.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ value_compile = {
109109
elseif t == "index" then
110110
return "[", self:value(arg), "]"
111111
elseif t == "dot" then
112-
return ".", self:value(arg)
112+
return ".", tostring(arg)
113113
elseif t == "colon" then
114114
return ":", arg, chain_item(node[3])
115115
elseif t == "colon_stub" then

moonscript/compile/value.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ value_compile =
6666
elseif t == "index"
6767
"[", @value(arg), "]"
6868
elseif t == "dot"
69-
".", @value arg
69+
".", tostring arg
7070
elseif t == "colon"
7171
":", arg, chain_item(node[3])
7272
elseif t == "colon_stub"

tests/inputs/class.moon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,15 @@ with Hello!
6969
print x
7070
x!
7171

72+
class CoolSuper
73+
hi: =>
74+
super(1,2,3,4) 1,2,3,4
75+
super.something 1,2,3,4
76+
super.something(1,2,3,4).world
77+
super\yeah"world".okay hi, hi, hi
78+
something.super
79+
super.super.super.super
80+
nil
81+
82+
83+

tests/outputs/class.lua

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,39 @@ do
298298
x = _with_0:something()
299299
print(x)
300300
x()
301-
end
301+
end
302+
local CoolSuper
303+
CoolSuper = (function()
304+
local _parent_0 = nil
305+
local _base_0 = {
306+
hi = function(self)
307+
_parent_0.hi(self, 1, 2, 3, 4)(1, 2, 3, 4)
308+
_parent_0.something(1, 2, 3, 4)
309+
local _ = _parent_0.something(1, 2, 3, 4).world
310+
_parent_0.yeah(self, "world").okay(hi, hi, hi)
311+
_ = something.super
312+
_ = _parent_0.super.super.super
313+
return nil
314+
end
315+
}
316+
_base_0.__index = _base_0
317+
if _parent_0 then
318+
setmetatable(_base_0, getmetatable(_parent_0).__index)
319+
end
320+
local _class_0 = setmetatable({
321+
__init = function(self, ...)
322+
if _parent_0 then
323+
return _parent_0.__init(self, ...)
324+
end
325+
end
326+
}, {
327+
__index = _base_0,
328+
__call = function(cls, ...)
329+
local _self_0 = setmetatable({}, _base_0)
330+
cls.__init(_self_0, ...)
331+
return _self_0
332+
end
333+
})
334+
_base_0.__class = _class_0
335+
return _class_0
336+
end)()

0 commit comments

Comments
 (0)