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: Missing parentheses after line break #16122

Merged
merged 2 commits into from Nov 28, 2023

Conversation

liuxingbaoyu
Copy link
Member

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

Ref: #16104

@liuxingbaoyu liuxingbaoyu added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: generator i: regression labels Nov 24, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented Nov 24, 2023

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

Comment on lines 1041 to 1042
_parenPushNewlineState?.printed === false &&
lastCharCode != charCodes.lineFeed &&
Copy link
Member

Choose a reason for hiding this comment

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

Is there a case in which _parenPushNewlineState?.printed is false, lastCharCode is charCodes.lineFeed and we do not need to print the parenthesis?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry I didn't understand what you meant, if lastCharCode is charCodes.lineFeed then it will not continue.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant: if we deleted the lastCharCode != charCodes.lineFeed && check, there would be any difference?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, thank you! There is no difference between them. When lastCharCode is charCodes.lineFeed, _parenPushNewlineState?.printed must be true

@kungfooman
Copy link

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

Is this true? I can't find a way to access parse and give it the {compact: true} option:

image

@liuxingbaoyu
Copy link
Member Author

#11696
Yes, this is not exported yet.

@nicolo-ribaudo nicolo-ribaudo merged commit ce60d99 into babel:main Nov 28, 2023
48 checks passed
@nicolo-ribaudo nicolo-ribaudo changed the title fix: Miss parentheses after line break fix: Missing parentheses after line break Nov 28, 2023
@artemdemo
Copy link

Hey guys, when are you planning to release it?
We're broken because if this :(

@liuxingbaoyu liuxingbaoyu deleted the fix-paren-comment branch November 29, 2023 09:13
@nicolo-ribaudo
Copy link
Member

We can release today

@nicolo-ribaudo
Copy link
Member

Doing it now, it will take ~20 mins

@artemdemo
Copy link

Thank you, appreciate it 🙏

Vylpes pushed a commit to Vylpes/random-bunny that referenced this pull request Dec 4, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@babel/traverse](https://babel.dev/docs/en/next/babel-traverse) ([source](https://github.com/babel/babel)) | resolutions | patch | [`7.23.3` -> `7.23.5`](https://renovatebot.com/diffs/npm/@babel%2ftraverse/7.23.3/7.23.5) |

---

### Release Notes

<details>
<summary>babel/babel (@&#8203;babel/traverse)</summary>

### [`v7.23.5`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7235-2023-11-29)

[Compare Source](babel/babel@v7.23.4...v7.23.5)

##### 👓 Spec Compliance

-   `babel-plugin-proposal-decorators`
    -   [#&#8203;16138](babel/babel#16138) Class binding is in TDZ during decorators initialization ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-helpers`, `babel-plugin-proposal-decorators`
    -   [#&#8203;16132](babel/babel#16132) Allow addInitializer in field decorator context ([@&#8203;JLHwung](https://github.com/JLHwung))

##### 🐛 Bug Fix

-   `babel-traverse`, `babel-types`
    -   [#&#8203;16131](babel/babel#16131) Do not remove bindings when removing assignment expression path ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-plugin-transform-classes`
    -   [#&#8203;16135](babel/babel#16135) Require class properties transform when compiling class with private fields ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-generator`
    -   [#&#8203;16122](babel/babel#16122) fix: Missing parentheses after line break ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))
-   `babel-helpers`
    -   [#&#8203;16130](babel/babel#16130) Fix helpers internal fns names conflict resolution  ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-helper-create-class-features-plugin`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-typescript`
    -   [#&#8203;16123](babel/babel#16123) Simplify class fields injetion after `super()` ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-generator`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-parameters`, `babel-plugin-transform-typescript`, `babel-traverse`
    -   [#&#8203;16110](babel/babel#16110) fix: Unexpected duplication of comments ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))
-   `babel-eslint-plugin`
    -   [#&#8203;16023](babel/babel#16023) Add `@babel/eslint-plugin/no-undef` to fix `no-undef` with accessor props ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))

##### 🔬 Output optimization

-   `babel-helpers`
    -   [#&#8203;16129](babel/babel#16129) Optimize `decorator` helper size ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

### [`v7.23.4`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7234-2023-11-20)

[Compare Source](babel/babel@v7.23.3...v7.23.4)

##### 🐛 Bug Fix

-   `babel-generator`
    -   [#&#8203;16104](babel/babel#16104) fix: Pure comments missing parentheses ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/113
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
@dubzzz
Copy link

dubzzz commented Dec 11, 2023

👋 I think I have a regression when bumping @babel/generator that could be linked to this precise PR. I'm currently investigating, but I get a crash in:

let indentSize = this.format.retainLines ? 0 : this._buf.getCurrentColumn();  // debug: this.format.retainLines=true
if (this._shouldIndent(47) || this.format.retainLines) {  // debug: this._shouldIndent(47)=undefined
  indentSize += this._getIndent(); // debug: indentSize reaches -2 after that update
}
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);   // CRASH occurs here

The crash seems to indicate that repeat receives a negative figure: Invalid count value: -2. I'm currently trying to confirm by extracting a minimal repro.

UPDATE: Has been fixed following #16165

@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 Mar 12, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator 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.

None yet

7 participants