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 printing BigIntLiterals/DecimalLiterals with compact option #12424

Merged
merged 1 commit into from Dec 1, 2020

Conversation

existentialism
Copy link
Member

@existentialism existentialism commented Nov 30, 2020

Q                       A
Fixed Issues? Fixes #12423
Patch: Bug Fix? Y
License MIT

@existentialism existentialism added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Nov 30, 2020
@babel-bot
Copy link
Collaborator

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

@@ -216,19 +216,19 @@ export function StringLiteral(node: Object) {
export function BigIntLiteral(node: Object) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw != null) {
this.token(raw);
this.word(raw);
Copy link
Member Author

Choose a reason for hiding this comment

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

@nicolo-ribaudo @JLHwung we could also use this.number here if clearer (though there's logic in there for handling integer tokens), thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe let's add a comment explaining that we use word instead of number to avoid that additional logic?

@codesandbox-ci
Copy link

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 84fb9a1:

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

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

I think we could add a compact: true test runner for @babel/generator, like we did for estree in @babel/parser. Essentially we shall enforce the following idempotent invariance:

generate(ast, { compact: true }) === generate(parse(generate(ast, { compact: true })), { compact: true })

@existentialism
Copy link
Member Author

@JLHwung yeah been thinking of doing this for a while, will take a look

@existentialism existentialism changed the title Fix printing BigIntLiterals and DecimalLiterals with compact option Fix printing BigIntLiterals/DecimalLiterals with compact option Dec 1, 2020
@existentialism existentialism merged commit 7018ed6 into main Dec 1, 2020
@existentialism existentialism deleted the issue12423 branch December 1, 2020 02:18
nicolo-ribaudo pushed a commit to nicolo-ribaudo/babel that referenced this pull request Dec 2, 2020
@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 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2021
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 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.

compact: true causes space between return and bigint literal to be omitted
5 participants