Re: [heycam/webidl] Add bigint type (#525)

Infix arithmetic operations work on BigInt and Number, but both operands need to be either BigInt or Number, not mixed.

Overloading like 
```
a(double x);
a(bigint x);
```
would not cause an implicit conversion from Number to BigInt; it would just call `ToNumeric` on the argument, which would call `valueOf` on objects, and convert strings to Number, and leave Numbers and BigInts in place. That's just like what arithmetic operations like unary `-` do--still no implicit conversion from Number to BigInt, but also keeping in place all the existing conversions.

If you define `c(bigint x);`, this will call ToNumeric, and which calls valueOf but doesn't convert a Number to a BigInt; it will just throw on Number. (That's the case whether or not we allow the overloading.)

The patch currently out for review permits unions like `(double or bigint)` (I don't see any particular way to prohibit it), but if it's checking for membership of a numeric value in a union like that, it will throw an error.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/525#issuecomment-445275856

Received on Friday, 7 December 2018 15:55:42 UTC