Skip to content

fix parentheses around sequence expression as body of arrow chain #11593

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

Merged
merged 4 commits into from
Sep 27, 2021

Conversation

bakkot
Copy link
Collaborator

@bakkot bakkot commented Sep 27, 2021

Description

Fixes #10955.

#9992 introduced a special case for printing the bodies of chained arrows, which has very different logic from printing a regular arrow. It neglected to copy over the logic to handle this case.

Checklist

  • I’ve added tests to confirm my change works.
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

Sorry, something went wrong.

@bakkot
Copy link
Collaborator Author

bakkot commented Sep 27, 2021

Sidebar: is there a reason #9992 is using line instead of softline? It means that even when the chain fits on one line, as in

const f = () => ({ k }) => k;

it will get split across multiple lines, as in

const f =
  () =>
  ({ k }) =>
    k;

That seems obviously wrong to me; I'd be happy to submit a PR fixing it.

@fisker
Copy link
Member

fisker commented Sep 27, 2021

@bakkot Have you seen #10955? I think we already have code for this

// We handle sequence expressions as the body of arrows specially,
, but we returned too early .

@bakkot
Copy link
Collaborator Author

bakkot commented Sep 27, 2021

@fisker I wrote that comment. And yes, the problem is that #9992 introduced a return before the logic which handles sequence expressions, as I said in the description; the fix is to have the new code handle sequence expressions as well.

@fisker
Copy link
Member

fisker commented Sep 27, 2021

Sorry, I didn't see the description.

I don't like coping the existing code, but seems hard to reuse?

Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Member

@sosukesuzuki sosukesuzuki left a comment

Choose a reason for hiding this comment

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

Thank you! But please update changelog.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
@sosukesuzuki sosukesuzuki merged commit b86d36a into prettier:main Sep 27, 2021
@bakkot bakkot deleted the paren-seq-arrow-chain branch September 27, 2021 20:35
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using compound expression with comma operator as return value of curried function
3 participants