Skip to content

Syntax error on JavaScript for specific number syntax #4459

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

Closed
GearsDatapacks opened this issue Apr 7, 2025 · 0 comments · Fixed by #4460
Closed

Syntax error on JavaScript for specific number syntax #4459

GearsDatapacks opened this issue Apr 7, 2025 · 0 comments · Fixed by #4460

Comments

@GearsDatapacks
Copy link
Member

In Gleam, numbers are allowed to look something like this: 0x_abcd, whereas in JavaScript, the 0x prefix (along with 0b and 0o) cannot be followed immediately by an underscore.
Since the Gleam compiler currently performs no transformation on numbers when compiling to JavaScript, this causes a syntax error.
This is not a problem on Erlang as the compiler already has to transform 0x in 16#, and the invalid syntax is eliminated in the process.
We can probably just check for 0b_, 0x_ and 0o_ at the start of numbers and remove the underscore in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant