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

[flow] Fix parsing of arrows in conditional expressions in parentheses #13655

Merged

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Aug 7, 2021

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

This was challenging, but the fixed code has less lines than the old code 😎

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: flow pkg: parser labels Aug 7, 2021
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:13)"
"throws": "Unexpected token (1:12)"
Copy link
Member Author

Choose a reason for hiding this comment

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

The input code is const f = (x?). The old error position was at ); now it's at ?.

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token, expected \",\" (1:65)"
"throws": "Unexpected token (1:65)"
Copy link
Member Author

Choose a reason for hiding this comment

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

The input code is a ? b : c ? d : e ? f : g ? h : i ? j : k ? l : m ? n : (o ? p : =);. The old error message was wrong, since there is no way we could expect , instead of =.

@babel-bot
Copy link
Collaborator

babel-bot commented Aug 7, 2021

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 7, 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 985dceb:

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

@nicolo-ribaudo nicolo-ribaudo merged commit e721f61 into babel:main Aug 10, 2021
@nicolo-ribaudo nicolo-ribaudo deleted the flow-arrows-in-ternaries-in-parens branch August 10, 2021 18:46
sosukesuzuki added a commit to sosukesuzuki/prettier that referenced this pull request Aug 18, 2021
sosukesuzuki added a commit to prettier/prettier that referenced this pull request Aug 18, 2021
* Add tests for babel/babel#13659

* Add tests for babel/babel#13655

* Add tests for babel/babel#13645

* Update tests
fisker pushed a commit to prettier/prettier that referenced this pull request Aug 18, 2021
* Build(deps): Bump @babel/parser from 7.15.2 to 7.15.3

Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.15.2 to 7.15.3.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.15.3/packages/babel-parser)

---
updated-dependencies:
- dependency-name: "@babel/parser"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add tests for `@babel/parser` 7.15.3 (#11366)

* Add tests for babel/babel#13659

* Add tests for babel/babel#13655

* Add tests for babel/babel#13645

* Update tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
@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 Nov 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: flow 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]: Error when parsing ternary inside parens with arrow functions when using Flow
5 participants