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

[JavaScript] Fix comma after ternary expression #3986

Merged

Conversation

deathaxe
Copy link
Collaborator

@deathaxe deathaxe commented May 9, 2024

Fixes #3985

This PR sets expression instead of expression-no-comma onto stack after ternary expressions, so they can appear in the middle of sequences.

@deathaxe deathaxe merged commit 3c25c09 into sublimehq:master May 9, 2024
2 checks passed
@deathaxe deathaxe deleted the pr/javascript/fix-comma-after-ternary branch May 9, 2024 16:10
deathaxe added a commit to deathaxe/sublime-packages that referenced this pull request Aug 5, 2024
This commit fixes a regression, introduced by sublimehq#3986, which breaks syntax
highlighting in objects, as comma is no longer consumed as key-value-pair
separator.

It's not the ternary expression, which allows commas, but the for statement,
which allows multiple expressions, separated by comma after `in` keyword.

    for (var in <expr>, <expr>, ...)

    expr: any valid expression, maybe ternary, maybe function-call

The change to ternary expressions is reverted and for-condition context is
modified instead to allow multiple expressions after `in` keyword.

Also scope `;` invalid if there are too many.
deathaxe added a commit that referenced this pull request Aug 6, 2024
* [JavaScript] Fix ternary operator regression

This commit fixes a regression, introduced by #3986, which breaks syntax
highlighting in objects, as comma is no longer consumed as key-value-pair
separator.

It's not the ternary expression, which allows commas, but the for statement,
which allows multiple expressions, separated by comma after `in` keyword.

    for (var in <expr>, <expr>, ...)

    expr: any valid expression, maybe ternary, maybe function-call

The change to ternary expressions is reverted and for-condition context is
modified instead to allow multiple expressions after `in` keyword.

Also scope `;` invalid if there are too many.

* [JavaScript] Tweak for-conditon context switching

This commit...

1. adds a `pop: 1` to the pattern of `for-condition` to make sure at most
   one opening parenthesis after for is consumed as loop condition.

   The following may have happened before.

       for (...) (...)

2. Tweaks how `meta.group` is applied as it sometimes makes a difference,
   whether a scope is a `meta_scope` or not, especially related with
   `clear_scopes` keyword.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug in syntax of javascript
3 participants