[whatwg/webidl] Intent to use BigInt/numeric union (Issue #1388)

### What is the issue with the Web IDL Standard?

Opening an issue per the wording here: https://webidl.spec.whatwg.org/#limit-bigint-numeric-unions

> It would not be appropriate to accept such a union, only to then convert values of the numeric type to a bigint for further processing, as this runs the risk of introducing precision errors. Please [file an issue](https://github.com/whatwg/webidl/issues/new?title=Intent%20to%20use%20bigint/numeric%20union) before using this feature.

We have 3 use cases in WebNN where we need to be able to accept full precision from the API and retain it passed all the way down to the bottom, because float64 cannot express the full precision of int64.

- adding padding (https://github.com/webmachinelearning/webnn/issues/442)
- clamping a range (https://github.com/webmachinelearning/webnn/issues/442)
- filling in a tensor with sequential values (https://github.com/webmachinelearning/webnn/issues/492)

Evidently it's murky territory, as Bin Miao [hit a bug](https://github.com/webmachinelearning/webnn/issues/492#issuecomment-1926419539) in the Chromium implementation "We met the problem of using the keyword `or` in IDL to create a union type containing double and bigint. In the generated file 'v8_union_bigint_double.cc', it was only judged that the incoming data was of JS number type and there is no judgment that it is BigInt, which causes an error to be reported when BigInt data is passed in when calling this API using JS code.", and [Joshua notes](https://github.com/webmachinelearning/webnn/issues/492#issuecomment-1949517393) that "Use of bigint is extremely limited in Chromium at the moment, so I'm not surprised if the binding code generation can't handle a union with it yet ... this may just be the first spec".

FYI @inexorabletash, @annevk, @honry, @miaobin

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1388
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1388@github.com>

Received on Saturday, 17 February 2024 03:57:35 UTC