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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ast.ls
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,7 @@ class exports.Case extends Node
if type is \match
for test, i in tests
tar = Chain target .add Index (Literal i), \., true
tests[i] = Chain test .auto-compare (if target then [tar] else null)
tests[i] = Parens (Chain test .auto-compare (if target then [tar] else null))
if bool
binary = if type is \match then \&& else \||
[t] = tests
Expand Down
5 changes: 5 additions & 0 deletions test/switch.ls
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,8 @@ x = -2
match x
| -2 => ok 1
| _ => ok 0

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