-
Notifications
You must be signed in to change notification settings - Fork 452
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 bigint div/mod to throw native RangeError #7154
base: master
Are you sure you want to change the base?
Conversation
I don't think I fully understand the intention of this PR. Why do we remove the check for RangeError (Division by zero) that could occur at runtime? |
We threw a similar but own custom error |
I think it should at least be distinguishable from regular integer errors. |
Or I think it would be better to have per-module definitions of exceptions like Any thoughts on this suggestion? @cknitt @cristianoc |
Without sub typing it seems strange to have to know where the exception is coming from. |
sub typing? int and bigint have nothing to do with each other. |
Exactly: there's no way to catch all division by zero other than listing them all. This imposes some refactoring overhead and possible foot guns when toggling between using int and bigint. That's the downsides. I'm not sure about upsides. |
I was thinking a little more in terms of JavaScript. Dividing a regular number by 0 returns But bigint is more explicit about everything. All operations on bigint are incompatible with numbers, and there are even no implicit conversions between them. You mentioned listing of errors, but that's actually the case. Since the two operations never mix, there are two ways to track its cause originally in Js: checking |
Another problem is that |
It is true that if one wants to publish a library for consumption by JS then one better not change the semantics. The question remains of what to do with int as |
That's another feature we need to support natively, for all of JS' built-in Error classes |
There is no infinity or nan for bigint.
No need to check
int
semantic IMHO, bigint works totally different with number (int & float) anyway