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

Evaluate some BigInt operations #1390

Merged
merged 2 commits into from
Feb 19, 2024
Merged

Evaluate some BigInt operations #1390

merged 2 commits into from
Feb 19, 2024

Conversation

fabiosantoscode
Copy link
Collaborator

Not confident enough to release this right now because handling BigInt can cause a bunch of TypeErrors, both in Terser and output code.

@fabiosantoscode
Copy link
Collaborator Author

To do: avoid dividing by zero!

@dead-claudia
Copy link

To do: avoid dividing by zero!

@fabiosantoscode You might be able to get away with a sentinel value (say, a special object or symbol) and using that for a synthetic "not-a-number" value for bigints. That may be easier to fuse in since it'll require less code motion. Then, in the end, you can render that synthetic value to a single representation like 0n/0n (along with maybe a compiler warning) to ensure the TypeError ultimately gets thrown in the end.

@fabiosantoscode
Copy link
Collaborator Author

I think I'll just make 1234n / 0n transform into itself (simply return this). This is way too much of a corner case in my opinion, if someone wrote code that will 100% crash they can afford a couple extra bytes, nobody does this normally

@fabiosantoscode
Copy link
Collaborator Author

fabiosantoscode commented May 18, 2023

The TODO was just to avoid Terser itself crashing

@dead-claudia
Copy link

@fabiosantoscode Fair enough. I was just giving a stray suggestion.

@fabiosantoscode fabiosantoscode merged commit cf27499 into master Feb 19, 2024
10 checks passed
@fabiosantoscode fabiosantoscode deleted the bigint-eval branch February 23, 2024 15:18
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 this pull request may close these issues.

None yet

2 participants