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

Wrap match-cases in parens #812

Merged
merged 2 commits into from
Feb 4, 2016
Merged

Wrap match-cases in parens #812

merged 2 commits into from
Feb 4, 2016

Conversation

igl
Copy link
Contributor

@igl igl commented Jan 13, 2016

This fixes #584 and makes match a quite powerful pattern-matching tool.
Test included.

Compiles:

match 1, 3, 3
| 1, 1, 2 or 3 => ok 0
| 1, 2 or 3, 3 => ok 1
| _            => ok 0

To:

// Generated by LiveScript 1.4.0
(function(){
  var ref$;
  switch (ref$ = [1, 3, 3], false) {
  case !(1 === ref$[0] && 1 === ref$[1] && (2 === ref$[2] || 3 === ref$[2])):
    ok(0);
    break;
  case !(1 === ref$[0] && (2 === ref$[1] || 3 === ref$[1]) && 3 === ref$[2]):
    ok(1);
    break;
  default:
    ok(0);
  }
}).call(this);

@igl igl mentioned this pull request Jan 13, 2016
vendethiel added a commit that referenced this pull request Feb 4, 2016
Wrap match-cases in parens
@vendethiel vendethiel merged commit 01e1c11 into gkz:master Feb 4, 2016
@vendethiel
Copy link
Contributor

Thanks.

@igl igl deleted the match-parens branch February 5, 2016 13:35
@igl
Copy link
Contributor Author

igl commented Feb 5, 2016

😗

@vendethiel
Copy link
Contributor

I wanted to find another fix (changing LEVEL_PAREN below), but since I didn't figure out the problem offhand... Thanks! :)

This was referenced Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pattern-match and, and, or
2 participants