Skip to content

Commit cd5087b

Browse files
committed
don't error on value named super outside class
1 parent fc72baf commit cd5087b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

moonscript/compile/value.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ value_compile = {
309309
return "self:" .. self:value(node[2])
310310
end,
311311
raw_value = function(self, value)
312-
if value == "super" then
313-
return self:value(self:get("super")(self))
312+
local sup = self:get("super")
313+
if value == "super" and sup then
314+
return self:value(sup(self))
314315
end
315316
if value == "..." then
316317
self.has_varargs = true

moonscript/compile/value.moon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ value_compile =
181181

182182
-- catch all pure string values
183183
raw_value: (value) =>
184-
if value == "super"
185-
return @value @get"super" self
184+
sup = @get"super"
185+
if value == "super" and sup
186+
return @value sup self
186187

187188
if value == "..."
188189
@has_varargs = true

0 commit comments

Comments
 (0)