Skip to content
New issue

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

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

Already on GitHub? # to your account

Default case in the middle of a switch doesn't fallthrough correctly #423

Closed
ykagan opened this issue Feb 14, 2017 · 0 comments · Fixed by #482
Closed

Default case in the middle of a switch doesn't fallthrough correctly #423

ykagan opened this issue Feb 14, 2017 · 0 comments · Fixed by #482
Labels
bug Confirmed bug has PR Has an open PR that fixes this issue

Comments

@ykagan
Copy link

ykagan commented Feb 14, 2017

Simple example here:
function foo(bar) { switch (bar) { case 'a': return 1; case 'b': default: return 2; case 'c': return 3; } }

This results in incorrect output:

function foo(a){return'a'===a?1:'b'===a||'c'===a?3:2}

where 'b' returns 3 instead of 2. It looks like babili fails to detect that 'b' should fallthrough to the default case when it converts the switch statement into a conditional.

@boopathi boopathi added the bug Confirmed bug label Feb 15, 2017
vigneshshanmugam added a commit to vigneshshanmugam/babili that referenced this issue Mar 21, 2017
@vigneshshanmugam vigneshshanmugam added the has PR Has an open PR that fixes this issue label Mar 22, 2017
boopathi pushed a commit that referenced this issue Mar 22, 2017
* handle default statements with fallthrough properly [fix #423]

* add multiple fallthrough test case
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Confirmed bug has PR Has an open PR that fixes this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants