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

Already on GitHub? Sign in to your account

Allow 'break' in switch case + curly braces #1161

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
Contributor

aknow commented Jul 4, 2013

For issue #858

cowwoc commented Aug 6, 2013

You need to also support return inside a block, not just break.

Contributor

aknow commented Aug 7, 2013

I have add the same handle for return in switch. How about this version?

Skalman commented Aug 7, 2013

I have no idea whether it's outside the scope of this issue, but:

  • It should also handle throw
  • It should perform complete flow analysis and figure out whether all blocks eventually break out of the switch
switch (v) {
    case 1: {
        if (a) {
            // ...
            break;
        } else {
            // ...
            break;
        }
    }
    case 2: {
        // ...
    }
}

cowwoc commented Aug 7, 2013

@Skalman My guess is that adding support for throw is trivial but doing a complete flow analysis is going to be more complex. Perhaps we can treat the two as separate issues?

Skalman commented Aug 7, 2013

@cowwoc Yeah, I realize that flow analysis is a huge undertaking. Just wanted to mention that JSHint should do that too. ;-)

Contributor

aknow commented Aug 9, 2013

OK. Add the throw.
Flow analysis might be a big job.

Owner

valueof commented Aug 15, 2013

The code looks good but we will need a test case (see tests/unit for more info) to merge it in. Thanks!

Contributor

aknow commented Aug 16, 2013

Test case done.

valueof added a commit that referenced this pull request Oct 17, 2013

Fixed #858: Allow 'break' and blocks in switch cases.
Closes #1161.

Signed-off-by: Anton Kovalyov <anton@kovalyov.net>
Owner

valueof commented Oct 17, 2013

Hm, it seems that GitHub doesn't auto-close bugs unless commits are in master. Oh well. I've merged your patch, thanks!

@valueof valueof closed this Oct 17, 2013

jugglinmike added a commit to jugglinmike/jshint that referenced this pull request Oct 21, 2014

Fixed #858: Allow 'break' and blocks in switch cases.
Closes #1161.

Signed-off-by: Anton Kovalyov <anton@kovalyov.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment