-
Notifications
You must be signed in to change notification settings - Fork 352
jsParensError for parenthesized arrow function #364
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
Comments
Good find, this is part of the challenge with arrow functions in general. Finding the specific commit is probably not necessary, I'll take a look. |
It was something in #363. I've played around a bit, but so far haven't determined exactly which change is responsible. |
I just ran into this; it's 36f34b2 according to |
Reverting this change fixes the issue: -syntax match jsArrowFuncArgs /(\(\k\|,\|\s\|\n\|\.\)*)\s\+\(=>\)\@=/ skipwhite contains=jsFuncArgs extend
+syntax match jsArrowFuncArgs /(\%(.\)*)\s*\(=>\)\@=/ skipempty skipwhite contains=jsFuncArgs nextgroup=jsArrowFunction |
It's the greedy A quick fix is changing that to the non-greedy equivalent |
Thanks for investigating, @tomxtobin!
It's not valid to have |
@davidchambers I think it is valid to have something like: (x = (2 + 3)) => {} Ideally the requirements for this regex are:
Some crazier examples that make this regex really hard to do right: ((x = (2 + 3)) => { return x; })();
((x = (true ? 1 : 3)) => { return x; })();
((x = (true ? event => event.response : () => { return error.response; })) => { return x; })();
var multiline = ({
x = 2,
y = false
}) => {
console.log()
} |
Oh! I wasn't aware of this, @amadeus. The problem is trickier than I imagined. |
I mean, to be fair, just because people could write such shitty and hard to read code, doesn't mean they should. To paraphrase a brilliant friend of mine, we may be reaching the limits of what a regex can interpret in a complex language. |
Like, ideally, |
Ok, so this issues is pretty bad, and I think a good workaround in the meantime, until we can get it properly fixed is to comment out the |
So, I've been playing with things a bit, and I have something that works pretty well, with a few caveats: 9b58fcc Some notes:
I've done some research into other editors, like Sublime and Atom, and all seem to break down if you incorporate new lines into the arguments section or if you use lambdas or parens inside the destructuring statement, so that's not a huge issue imo. |
A basic version of this is fixed in |
I just noticed that the closing parens in the following line is marked as
jsParensError
:The same applies in this case:
This also exhibits the problem:
Interestingly, this does not:
When I have a bit more time I will run
git bisect
to determine which change is responsible.The text was updated successfully, but these errors were encountered: