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

a better error message for disallowed trailing commas/additional parameters after rest elements in function params #9046

Merged
merged 4 commits into from Nov 21, 2018

Conversation

morozRed
Copy link
Contributor

Q                       A
Fixed Issues? Fixes #7460
Patch: Bug Fix? n
Major: Breaking Change? n
Minor: New Feature? n
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR changes error message when we had other parameters after rest element.

Previous behaviour:

Test:

(
    first,
    ...second,
    third
) => {};

Result

Unexpected token, expected ")"

New behaviour:

Test:

(
    first,
    ...second,
    third
) => {};

Result:

Rest parameter must be last formal parameter

@babel-bot
Copy link
Collaborator

babel-bot commented Nov 20, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9419/

) {
this.raise(
this.state.start,
"Rest parameter must be last formal parameter",
Copy link
Member

@xtuc xtuc Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, It looks good to me.

At first the error mesage looked odd to me, but it's actually V8's one 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xtuc thanks! I'm glad that my first PR was not bad 😃 Yeah, I decided to get this message from V8.

@existentialism existentialism added PR: Polish 💅 A type of pull request used for our changelog categories and removed PR: New Feature 🚀 A type of pull request used for our changelog categories labels Nov 20, 2018
@nicolo-ribaudo
Copy link
Member

Could you add a test for (...rest,) => {}?

@morozRed
Copy link
Contributor Author

@nicolo-ribaudo yeah, sure

@nicolo-ribaudo
Copy link
Member

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a better error message for disallowed trailing commas after rest elements in function params
5 participants