Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`match` doesn't rebind `this` #926

andreivolt opened this Issue Oct 3, 2016 · 1 comment


None yet
1 participant
Copy link

andreivolt commented Oct 3, 2016

It seems that match doesn't do the right thing that switch does with this:

  match @bar
  | foo => bar

compiles to:

  foo: (function(){
    var ref$;
    switch (ref$ = [], false) {
    case !foo(ref$[0]):
      return bar;

rhendric added a commit to rhendric/LiveScript that referenced this issue Oct 3, 2016

Fix for gkz#926
This issue was caused by a failure of `traverse-children` to enter the
topic of a `match` statement (it worked fine with `switch`). This in
turn was because the Switch AST node, when representing a match, stored
its thing-to-match in a member called `target` instead of `topic`, but
'target' was not included in its list of child fields ('topic' was).

I couldn't see any use in keeping two distinct `topic` and `target`
fields, since they're never both used in the same node and never
referenced from other classes, so the issue was fixed by unifying them.

@gkz gkz closed this in 820cb37 Oct 3, 2016


This comment has been minimized.

Copy link

andreivolt commented Oct 3, 2016

wow, that was fast! thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.