Fix bigint div/mod to throw native RangeError#7154
Fix bigint div/mod to throw native RangeError#7154cometkim wants to merge 1 commit intorescript-lang:masterfrom
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 |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There is no infinity or nan for bigint.
No need to check
intsemantic IMHO, bigint works totally different with number (int & float) anyway