@leafo leafo released this Dec 7, 2015 · 93 commits to master since this release

Assets 2

You can now find windows binaries through GithHub's releases. See win32-v0.4.0

Changes to super

super now looks up the parent method via the class reference, instead of a
(fixed) closure to the parent class.

Given the following code:

class MyThing extends OtherThing
  the_method: =>

In the past super would compile to something like this:


Where _parent_0 was an internal local variable that contains a reference to
the parent class. Because the reference to parent is an internal local
variable, you could never swap out the parent unless resorting to the debug

This version will compile to:


Where _class_0 is an internal local variable that contains the current class (MyThing).

Another difference is that the instance method is looked up on __base instead
of the class. The old variation would trigger the metamethod for looking up on
the instance, but a class method of the same name could conflict, take
precedence, and be retuned instead. By referencing __base directly we avoid
this issue.

Super on class methods

super can now be used on class methods. It works exactly as you would expect.

class MyThing extends OtherThing
  @static_method: =>
    print super!

Calling super will compile to:


Improved scoping for super

The scoping of super is more intelligent. You can warp your methods in other
code and super will still generate correctly. For example, syntax like this
will now work as expected:

class Sub extends Base
  value: if debugging
    => super! + 100
    => super! + 10

  other_value: some_decorator {
    the_func: =>

super will refer to the lexically closest class declaration to find the name
of the method it should call on the parent.

Bug Fixes

  • Nested with blocks used incorrect ref (#214 by @geomaster)
  • Lua quote string literals had wrong precedence (#200 by @nonchip)
  • Returning from with block would generate two return statements (#208)
  • Including return or break in a continue wrapped block would generate invalid code (#215 #190 #183)


  • Refactor transformer out into multiple files
  • moon command line script rewritten in MoonScript
  • moonscript.parse.build_grammar function for getting new instance of parser grammar
  • Chain AST updated to be simpler