-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
False negative for arrow function with closing parenthesis in parameter list #15
Comments
You're right; although this is only possible in strict mode. I don't think a full parser is needed; there's probably other ways to check it reliably. |
Sorry, I'm not following. Default parameter values don't require strict mode...? In fact I was running that code in loose mode.
I don't see how, at least via |
By spec, yes, i believe they do - babel might allow it, but the language does not allow non-simple parameter lists in sloppy mode functions due to parsing difficulties. |
This strict mode thing is a sidetrack, since obviously we'd want
I don't think that's the case, can you point me at the part of the spec that says default parameter values are only allowed in strict mode?
If it's true strict mode is spec'd for this, I really want to know it. TIA. |
ahh, you're right - it's that a function with a non-simple parameter list can't change modes - ie, it can't be created in a sloppy mode context and attempt to become strict itself. (Definitely a sidetrack from the overall issue). See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Strict_Non_Simple_Params. |
That's fascinating, thanks. (With that hint, found it here.) It's interesting that it's any non-simple param list (including a rest param). If it were a param list containing expressions, I'd figure it was about the execution context between where the function appears and the function body, but a rest param doesn't do that. Huh. Maybe just to keep the rule simple. Thanks! |
For instance, if a default parameter value uses a function:
There are lots of ways to include a
)
in the parameter list. For instance,(a, b = (a)) => {}
(but who would write that? ... you know someone would :-) ).Sadly, I think the only way to deal with this would be to fire up a full parser, since a default can be anything, including a function definition with arbitrary code in it:
The text was updated successfully, but these errors were encountered: