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

IF statement inside of switch-when-else #3567

Closed
nick-skriabin opened this issue Aug 4, 2014 · 3 comments
Closed

IF statement inside of switch-when-else #3567

nick-skriabin opened this issue Aug 4, 2014 · 3 comments

Comments

@nick-skriabin
Copy link

Hello! There is a bug with compiling switch-when statements when there is if-then-else statement inside of it:

switch some_string
  when 'a' then console.log('a')
  when 'b' then if smth then console.log('smth') else console.log('smth else')

This will be compiled into this:

switch (some_string) {
  case 'a':
    console.log('a');
    break;
  case 'b':
    if (smth) {
      console.log('smth');
    }
    break;
  default:
    console.log('smth else');
}

instead of this:

switch (some_string) {
  case 'a':
    console.log('a');
    break;
  case 'b':
    if (smth) {
      console.log('smth');
    }
      console.log('smth else');
    }
}

But this code compiles as needed:

switch some_string
  when 'a'
    console.log('a')
  when 'b'
    if smth then console.log('smth') else console.log('smth else')

Thanks a lot!

@vendethiel
Copy link
Collaborator

I'm afraid this is a duplicate of #2342.

@vendethiel
Copy link
Collaborator

No, no I did not, @github.

@nick-skriabin
Copy link
Author

Oh, missed that. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants