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

fix: incorrect await rejection following arrow function in parameters (fixes #13872) #13928

Merged
merged 3 commits into from Nov 5, 2021

Conversation

The-x-Theorist
Copy link
Contributor

@The-x-Theorist The-x-Theorist commented Nov 4, 2021

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

When parsing an arrow expression, the error is raised when it reaches the stage where the function body is parsed and the expression scope is entered but never exited if the body is an expression.

@babel-bot
Copy link
Collaborator

babel-bot commented Nov 4, 2021

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 4, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit fe9c3d2:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@nicolo-ribaudo
Copy link
Member

Thanks for finding the problem! I'd prefer if we fixed this by moving the expressionScope.exit() call at line 2448 after the } that follows it, so that we keep an "one enter"-"one exit" correspondence in the code.

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Nov 4, 2021
@The-x-Theorist
Copy link
Contributor Author

Okay @nicolo-ribaudo I will change that.

@nicolo-ribaudo
Copy link
Member

Could you also add a test for yield?

(function* () {
  function f(_=()=>null) {}
  yield;
});

@The-x-Theorist
Copy link
Contributor Author

@nicolo-ribaudo Yeah, I will add test for yield too.

@JLHwung JLHwung merged commit a6a5269 into babel:main Nov 5, 2021
@The-x-Theorist The-x-Theorist deleted the incorrectly-rejects-await branch November 10, 2021 09:14
@The-x-Theorist The-x-Theorist restored the incorrectly-rejects-await branch November 10, 2021 09:14
@The-x-Theorist The-x-Theorist deleted the incorrectly-rejects-await branch November 10, 2021 09:15
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Feb 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2022
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: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: incorrectly rejects await when following a function with an arrow in default parameters
5 participants