Support for labeled blocks and lonely blocks #603

Closed
wants to merge 7 commits into
from

Projects

None yet

2 participants

@CarlEkerot

Added support for labeled blocks and lonely blocks, which are valid according to ECMA-262.
The following cases are tested and supported:

aLonelyBlock:
{
    // Labeled block
}
{
    // Unlabeled block
}

This fix also prevents the parser from halting when errors are present in statements after which a block is expected (f.ex. if-statements).
For example, the following will report error, but not halt parsing with Expected '(end)' and instead saw '}'. which it did before, due to the first { not being taken in to account, and the bracket-matching would fail:

if (a < b); {
    // Bad if-statement
}
CarlEkerot and others added some commits Aug 1, 2012
@CarlEkerot CarlEkerot Fix for issue #565. Makes blocks a special case of statements. This f…
…ix also prevents jshint from crashing due to unmatched curly-brackets in many cases (such as 'expected {, was (end)' in tests/unit/fixtures/comma.js)
7550336
@CarlEkerot CarlEkerot Removed commented addError-calls in parser.js. 03c8ee6
CarlEkerot Fix for issue #565. Makes blocks a special case of statements. This f…
…ix also prevents jshint from crashing due to unmatched curly-brackets in many cases (such as 'expected {, was (end)' in tests/unit/fixtures/comma.js)
e608f03
CarlEkerot Removed commented addError-calls in parser.js. 8d4f985
CarlEkerot Merge branch 'master' of https://github.com/CarlEkerot/jshint 2d65d8a
CarlEkerot Added assertions to ensure that code execution procedes after lonely …
…blocks, and that start-bracket errors doesn't halt the parsing.
f5ea569
CarlEkerot Merge remote branch 'upstream/master' d211d34
@valueof valueof added a commit that closed this pull request Aug 17, 2012
Carl Ekerot Add support for labeled and lonely blocks.
This patch adds support for labeled and lonely blocks which
are valid according to ECMA-262. The following cases are
tested and supported:

    aLabeledBlock:
    {
        // Labeled block
    }

    {
        // Unlabeled block
    }

This fix also prevents the parser from halting when errors
are present in statements after which a block is expected (e.g.
if-statements).

For example, the following will report error, but not halt parsing
with `Expected '(end)' and instead saw '}'.` which it did before,
due to the first { not being taken in to account, and the
bracket-matching would fail:

    if (a < b); {
        // Bad if-statement
    }

Issues:

Closes GH-603.

Squashed commit of the following:

commit 2eb909c1e20f3e581b0cf520c6cf9ede5620adf8
Merge: 38fe2c9 d211d34
Author: Anton Kovalyov <anton@kovalyov.net>
Date:   Thu Aug 16 21:32:42 2012 -0700

    Merge branch 'master' of git://github.com/CarlEkerot/jshint into CarlEkerot-master

commit d211d34
Merge: f5ea569 a1d7a7d
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Mon Aug 13 10:16:10 2012 +0200

    Merge remote branch 'upstream/master'

commit f5ea569
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Thu Aug 2 08:41:44 2012 +0200

    Added assertions to ensure that code execution procedes after lonely blocks, and that start-bracket errors doesn't halt the parsing.

commit 2d65d8a
Merge: 8d4f985 03c8ee6
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Wed Aug 1 11:53:39 2012 +0200

    Merge branch 'master' of https://github.com/CarlEkerot/jshint

commit 8d4f985
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Wed Aug 1 11:13:21 2012 +0200

    Removed commented addError-calls in parser.js.

commit e608f03
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Wed Aug 1 11:04:19 2012 +0200

    Fix for issue #565. Makes blocks a special case of statements. This fix also prevents jshint from crashing due to unmatched curly-brackets in many cases (such as 'expected {, was (end)' in tests/unit/fixtures/comma.js)

commit 03c8ee6
Author: Carl Ekerot <kalle@implode.se>
Date:   Wed Aug 1 11:13:21 2012 +0200

    Removed commented addError-calls in parser.js.

commit 7550336
Author: Carl Ekerot <kalle@implode.se>
Date:   Wed Aug 1 11:04:19 2012 +0200

    Fix for issue #565. Makes blocks a special case of statements. This fix also prevents jshint from crashing due to unmatched curly-brackets in many cases (such as 'expected {, was (end)' in tests/unit/fixtures/comma.js)
9ec3e3a
@valueof valueof closed this in 9ec3e3a Aug 17, 2012
@jugglinmike jugglinmike added a commit to jugglinmike/jshint that referenced this pull request Oct 21, 2014
Carl Ekerot Add support for labeled and lonely blocks.
This patch adds support for labeled and lonely blocks which
are valid according to ECMA-262. The following cases are
tested and supported:

    aLabeledBlock:
    {
        // Labeled block
    }

    {
        // Unlabeled block
    }

This fix also prevents the parser from halting when errors
are present in statements after which a block is expected (e.g.
if-statements).

For example, the following will report error, but not halt parsing
with `Expected '(end)' and instead saw '}'.` which it did before,
due to the first { not being taken in to account, and the
bracket-matching would fail:

    if (a < b); {
        // Bad if-statement
    }

Issues:

Closes GH-603.

Squashed commit of the following:

commit 2eb909c1e20f3e581b0cf520c6cf9ede5620adf8
Merge: 38fe2c9 d211d34
Author: Anton Kovalyov <anton@kovalyov.net>
Date:   Thu Aug 16 21:32:42 2012 -0700

    Merge branch 'master' of git://github.com/CarlEkerot/jshint into CarlEkerot-master

commit d211d34
Merge: f5ea569 a1d7a7d
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Mon Aug 13 10:16:10 2012 +0200

    Merge remote branch 'upstream/master'

commit f5ea569
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Thu Aug 2 08:41:44 2012 +0200

    Added assertions to ensure that code execution procedes after lonely blocks, and that start-bracket errors doesn't halt the parsing.

commit 2d65d8a
Merge: 8d4f985 03c8ee6
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Wed Aug 1 11:53:39 2012 +0200

    Merge branch 'master' of https://github.com/CarlEkerot/jshint

commit 8d4f985
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Wed Aug 1 11:13:21 2012 +0200

    Removed commented addError-calls in parser.js.

commit e608f03
Author: CarlEkerot <carl.ekerot@lunicore.se>
Date:   Wed Aug 1 11:04:19 2012 +0200

    Fix for issue #565. Makes blocks a special case of statements. This fix also prevents jshint from crashing due to unmatched curly-brackets in many cases (such as 'expected {, was (end)' in tests/unit/fixtures/comma.js)

commit 03c8ee6
Author: Carl Ekerot <kalle@implode.se>
Date:   Wed Aug 1 11:13:21 2012 +0200

    Removed commented addError-calls in parser.js.

commit 7550336
Author: Carl Ekerot <kalle@implode.se>
Date:   Wed Aug 1 11:04:19 2012 +0200

    Fix for issue #565. Makes blocks a special case of statements. This fix also prevents jshint from crashing due to unmatched curly-brackets in many cases (such as 'expected {, was (end)' in tests/unit/fixtures/comma.js)
54f17e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment