Skip to content

[compiler][patch] Emit unary expressions instead of negative numbers #33383

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 1 commit into from
Jun 2, 2025

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented May 30, 2025

This is a babel bug + edge case.

Babel compact mode produces invalid JavaScript (i.e. parse error) when given a NumericLiteral with a negative value.

See https://codesandbox.io/p/devbox/5d47fr for repro.

As a followup, we could change our test infra parse babel options (e.g. a babel transform options pragma) which could let us track regressions. We may add an "exhaustive" mode to the compiler test runner to test (1) different babel options and (2) commonly used versions.

This is a babel bug + edge case.

Babel compact mode produces invalid JavaScript (i.e. parse error) when given a `NumericLiteral` with a negative value.

See https://codesandbox.io/p/devbox/5d47fr for repro.

As a followup, we could change our test infra parse babel options (e.g. a babel transform options pragma) which could let us track regressions. We may add an "exhaustive" mode to the compiler test runner to test (1) different babel options and (2) commonly used versions.
@mofeiZ
Copy link
Contributor Author

mofeiZ commented Jun 2, 2025

Updated test runner to also use compact: true mode (no-op for all other test fixtures since we use prettier anyways) and added test case to prevent regression

@mofeiZ mofeiZ merged commit 526dd34 into main Jun 2, 2025
26 of 30 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 2, 2025
…33383)

This is a babel bug + edge case.

Babel compact mode produces invalid JavaScript (i.e. parse error) when
given a `NumericLiteral` with a negative value.

See https://codesandbox.io/p/devbox/5d47fr for repro.

DiffTrain build for [526dd34](526dd34)
github-actions bot pushed a commit that referenced this pull request Jun 2, 2025
…33383)

This is a babel bug + edge case.

Babel compact mode produces invalid JavaScript (i.e. parse error) when
given a `NumericLiteral` with a negative value.

See https://codesandbox.io/p/devbox/5d47fr for repro.

DiffTrain build for [526dd34](526dd34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants