Skip to content

Commit fa92cf3

Browse files
committed
Make handling of bigint/numberic unions, overloads more strict
If a string like "100000000000000000000000001" or "3.2" is passed to a method which has both a numeric and a bigint overload. API users may expect all cases to magically be handled correctly without information loss in both cases, but this behavior would require the type of the result to be based on the contents of the string. This patch avoids the issue with the following tweaks to BigInt WebIDL integration: - bigint and numeric types are marked as "indistinguishable", so it is not permitted to have an overload between bigint and a numeric type as the distinguishing argument. - In the es-to-union algorithm, if the type is a union containing bigint and a numeric type, and no more specific member applies for the conversion directly, then a TypeError is thrown.
1 parent 471ec88 commit fa92cf3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

index.bs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,7 +3522,7 @@ the following algorithm returns <i>true</i>.
35223522
<th>numeric types</th>
35233523
<td class="belowdiagonal"></td>
35243524
<td></td>
3525-
<td></td>
3525+
<td></td>
35263526
<td>●</td>
35273527
<td>●</td>
35283528
<td>●</td>
@@ -8077,9 +8077,11 @@ that correspond to the union’s [=member types=].
80778077
then return the result of
80788078
[=converted to an IDL value|converting=]
80798079
|V| to that type.
8080-
1. If |types| includes a [=numeric type=],
8081-
then return the result of [=converted to an IDL value|converting=]
8082-
|V| to that [=numeric type=].
8080+
1. If |types| includes a [=numeric type=], then:
8081+
1. If |types| includes {{bigint}},
8082+
[=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
8083+
1. Return the result of [=converted to an IDL value|converting=]
8084+
|V| to that [=numeric type=].
80838085
1. If |types| includes {{boolean}},
80848086
then return the result of [=converted to an IDL value|converting=]
80858087
|V| to {{boolean}}.

0 commit comments

Comments
 (0)