@@ -167,9 +167,11 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
167
167
text: SetFunctionName; url: sec-setfunctionname
168
168
text: SetImmutablePrototype; url: sec-set-immutable-prototype
169
169
text: SetIntegrityLevel; url: sec-setintegritylevel
170
+ text: ToBigInt; url: #sec-tobigint
170
171
text: ToBoolean; url: sec-toboolean
171
172
text: ToInt32; url: sec-toint32
172
173
text: ToNumber; url: sec-tonumber
174
+ text: ToNumeric; url: sec-tonumeric
173
175
text: ToObject; url: sec-toobject
174
176
text: ToPropertyDescriptor; url: sec-topropertydescriptor
175
177
text: ToPropertyKey; url: sec-topropertykey
@@ -195,6 +197,7 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
195
197
text: array index; url: array-index
196
198
text: array iterator object; url: sec-array-iterator-objects
197
199
text: built-in function object; url: sec-built-in-function-objects
200
+ text: BigInt; url: #sec-ecmascript-language-types-bigint-type
198
201
text: callable; for: ECMAScript; url: sec-iscallable
199
202
text: Completion Record; url: sec-completion-record-specification-type
200
203
text: constructor; url: constructor
@@ -3609,6 +3612,9 @@ the following algorithm returns <i>true</i>.
3609
3612
</div></th>
3610
3613
<th><div>
3611
3614
<span>numeric types</span>
3615
+ </div></th>
3616
+ <th><div>
3617
+ <span>bigint</span>
3612
3618
</div></th>
3613
3619
<th><div>
3614
3620
<span>string types</span>
@@ -3643,11 +3649,26 @@ the following algorithm returns <i>true</i>.
3643
3649
<td>●</td>
3644
3650
<td>●</td>
3645
3651
<td>●</td>
3652
+ <td>●</td>
3646
3653
</tr>
3647
3654
<tr>
3648
3655
<th>numeric types</th>
3649
3656
<td class="belowdiagonal"></td>
3650
3657
<td></td>
3658
+ <td></td>
3659
+ <td>●</td>
3660
+ <td>●</td>
3661
+ <td>●</td>
3662
+ <td>●</td>
3663
+ <td>●</td>
3664
+ <td>●</td>
3665
+ <td>●</td>
3666
+ </tr>
3667
+ <tr>
3668
+ <th>bigint</th>
3669
+ <td class="belowdiagonal"></td>
3670
+ <td class="belowdiagonal"></td>
3671
+ <td>(b)</td>
3651
3672
<td>●</td>
3652
3673
<td>●</td>
3653
3674
<td>●</td>
@@ -3660,6 +3681,7 @@ the following algorithm returns <i>true</i>.
3660
3681
<th>string types</th>
3661
3682
<td class="belowdiagonal"></td>
3662
3683
<td class="belowdiagonal"></td>
3684
+ <td class="belowdiagonal"></td>
3663
3685
<td></td>
3664
3686
<td>●</td>
3665
3687
<td>●</td>
@@ -3673,6 +3695,7 @@ the following algorithm returns <i>true</i>.
3673
3695
<td class="belowdiagonal"></td>
3674
3696
<td class="belowdiagonal"></td>
3675
3697
<td class="belowdiagonal"></td>
3698
+ <td class="belowdiagonal"></td>
3676
3699
<td></td>
3677
3700
<td>●</td>
3678
3701
<td></td>
@@ -3686,6 +3709,7 @@ the following algorithm returns <i>true</i>.
3686
3709
<td class="belowdiagonal"></td>
3687
3710
<td class="belowdiagonal"></td>
3688
3711
<td class="belowdiagonal"></td>
3712
+ <td class="belowdiagonal"></td>
3689
3713
<td></td>
3690
3714
<td>●</td>
3691
3715
<td>●</td>
@@ -3699,6 +3723,7 @@ the following algorithm returns <i>true</i>.
3699
3723
<td class="belowdiagonal"></td>
3700
3724
<td class="belowdiagonal"></td>
3701
3725
<td class="belowdiagonal"></td>
3726
+ <td class="belowdiagonal"></td>
3702
3727
<td>(a)</td>
3703
3728
<td>●</td>
3704
3729
<td>●</td>
@@ -3712,6 +3737,7 @@ the following algorithm returns <i>true</i>.
3712
3737
<td class="belowdiagonal"></td>
3713
3738
<td class="belowdiagonal"></td>
3714
3739
<td class="belowdiagonal"></td>
3740
+ <td class="belowdiagonal"></td>
3715
3741
<td></td>
3716
3742
<td></td>
3717
3743
<td>●</td>
@@ -3725,6 +3751,7 @@ the following algorithm returns <i>true</i>.
3725
3751
<td class="belowdiagonal"></td>
3726
3752
<td class="belowdiagonal"></td>
3727
3753
<td class="belowdiagonal"></td>
3754
+ <td class="belowdiagonal"></td>
3728
3755
<td></td>
3729
3756
<td>●</td>
3730
3757
</tr>
@@ -3738,6 +3765,7 @@ the following algorithm returns <i>true</i>.
3738
3765
<td class="belowdiagonal"></td>
3739
3766
<td class="belowdiagonal"></td>
3740
3767
<td class="belowdiagonal"></td>
3768
+ <td class="belowdiagonal"></td>
3741
3769
<td></td>
3742
3770
</tr>
3743
3771
</table>
@@ -3746,6 +3774,10 @@ the following algorithm returns <i>true</i>.
3746
3774
1. The two identified interface-like types are
3747
3775
not the same, and no single [=platform object=] implements both
3748
3776
interface-like types.
3777
+ 1. The types are distinguishable, but there is
3778
+ <a href="#limit-bigint-numeric-overloading">a separate restriction on their use in
3779
+ overloading</a> below. Please also note <a href="#limit-bigint-numeric-unions">the
3780
+ advice about using unions of these types</a>.
3749
3781
</ol>
3750
3782
3751
3783
<div class="example" id="example-distinguishability-diff-types">
@@ -3796,6 +3828,11 @@ for each pair of items the types at index |i| are [=distinguishable=].
3796
3828
The lowest such index is termed the <dfn id="dfn-distinguishing-argument-index" export>distinguishing argument index</dfn>
3797
3829
for the items of the [=effective overload set=] with the given type list size.
3798
3830
3831
+ <p id="limit-bigint-numeric-overloading">An [=effective overload set=] must not contain more than
3832
+ one [=list/item=] with the same [=type list=] [=list/size=], where one [=list/item=] has a
3833
+ {{bigint}} argument at the [=distinguishing argument index=] and another has a [=numeric type=]
3834
+ argument at the [=distinguishing argument index=].
3835
+
3799
3836
<div class="example">
3800
3837
3801
3838
Consider the [=effective overload set=] shown in the previous example.
@@ -5714,7 +5751,7 @@ the [=integer types=],
5714
5751
{{unrestricted double}}.
5715
5752
5716
5753
The <dfn id="dfn-primitive-type" export>primitive types</dfn> are
5717
- {{boolean}} and the [=numeric types=].
5754
+ {{bigint}}, {{ boolean}} and the [=numeric types=].
5718
5755
5719
5756
The <dfn id="dfn-string-type" export>string types</dfn> are
5720
5757
{{DOMString}}, all [=enumeration types=],
@@ -5820,6 +5857,7 @@ type.
5820
5857
"boolean"
5821
5858
"byte"
5822
5859
"octet"
5860
+ "bigint"
5823
5861
</pre>
5824
5862
5825
5863
<pre class="grammar" id="prod-UnrestrictedFloatType">
@@ -6096,6 +6134,16 @@ The [=type name=] of the
6096
6134
{{unrestricted double}} type is "<code>UnrestrictedDouble</code>".
6097
6135
6098
6136
6137
+ <h4 id="idl-bigint" interface>bigint</h4>
6138
+
6139
+ The {{bigint}} type is an arbitrary integer type, unrestricted in range.
6140
+
6141
+ {{bigint}} constant values in IDL are represented with
6142
+ <emu-t class="regex"><a href="#prod-integer">integer</a></emu-t> tokens.
6143
+
6144
+ The [=type name=] of the {{bigint}} type is “<code>BigInt</code>”.
6145
+
6146
+
6099
6147
<h4 oldids="dom-DOMString" id="idl-DOMString" interface>DOMString</h4>
6100
6148
6101
6149
The {{DOMString}} type corresponds to
@@ -6557,6 +6605,19 @@ Each pair of [=flattened member types=]
6557
6605
in a [=union type=], <var ignore>T</var> and <var ignore>U</var>,
6558
6606
must be [=distinguishable=].
6559
6607
6608
+ <p class="advisement" id="limit-bigint-numeric-unions">
6609
+ It is possible to create a union of {{bigint}} and a [=numeric type=].
6610
+ However, this is generally only supposed to be used for interfaces such as
6611
+ [[ECMA-402#numberformat-objects|NumberFormat]], which formats the values rather than using them in
6612
+ calculations.
6613
+ It would not be appropriate to accept such a union, only to then convert values of the
6614
+ [=numeric type=] to a {{bigint}} for further processing, as this runs the risk of introducing
6615
+ precision errors.
6616
+ Please
6617
+ <a href="https://github.com/heycam/webidl/issues/new?title=Intent%20to%20use%20bigint/numeric union">file an issue</a>
6618
+ before using this feature.
6619
+ </p>
6620
+
6560
6621
[=Union type=] constant values
6561
6622
in IDL are represented in the same way that constant values of their
6562
6623
[=member types=] would be
@@ -7086,6 +7147,7 @@ five forms are allowed.
7086
7147
"Promise"
7087
7148
"USVString"
7088
7149
"any"
7150
+ "bigint"
7089
7151
"boolean"
7090
7152
"byte"
7091
7153
"double"
@@ -7339,6 +7401,9 @@ ECMAScript value type.
7339
7401
1. If <a abstract-op>Type</a>(|V|) is Number, then
7340
7402
return the result of <a href="#es-to-unrestricted-double">converting</a> |V|
7341
7403
to an {{unrestricted double}}.
7404
+ 1. If <a abstract-op>Type</a>(|V|) is BigInt, then
7405
+ return the result of <a href="#es-to-bigint">converting</a> |V|
7406
+ to a {{bigint}}.
7342
7407
1. If <a abstract-op>Type</a>(|V|) is String, then
7343
7408
return the result of <a href="#es-DOMString">converting</a> |V|
7344
7409
to a {{DOMString}}.
@@ -7768,6 +7833,38 @@ value when its bit pattern is interpreted as an unsigned 64 bit integer.
7768
7833
{{unrestricted double}} value.
7769
7834
</div>
7770
7835
7836
+ <h4 id="es-bigint">bigint</h4>
7837
+
7838
+ <div id="es-to-bigint" algorithm="convert an ECMAScript value to a bigint">
7839
+
7840
+ An ECMAScript value |V| is [=converted to an IDL value|converted=]
7841
+ to an IDL {{bigint}} value by running the following algorithm:
7842
+
7843
+ 1. Let |x| be [=?=] [$ToBigInt$](|V|).
7844
+ 1. Return the IDL {{bigint}} value that represents the same numeric value as |x|.
7845
+ </div>
7846
+
7847
+ <div id="bigint-to-es" algorithm="convert a bigint to an ECMAScript value">
7848
+
7849
+ The result of [=converted to an ECMAScript value|converting=]
7850
+ an IDL {{bigint}} value to an ECMAScript value is a BigInt:
7851
+
7852
+ 1. Return the [=BigInt=] value that represents the same numeric value as the IDL {{bigint}}
7853
+ value.
7854
+ </div>
7855
+
7856
+ <div id="es-to-bigint-or-numeric" algorithm="convert an ECMAScript value to a numeric type or a bigint">
7857
+
7858
+ An ECMAScript value |V| is <dfn lt="converted to a numeric type or bigint">converted</dfn>
7859
+ to an IDL [=numeric type=] |T| or {{bigint}} value by running the following algorithm:
7860
+
7861
+ 1. Let |x| be [=?=] [$ToNumeric$](|V|).
7862
+ 1. If [$Type$](|x|) is BigInt, then
7863
+ 1. Return the IDL {{bigint}} value that represents the same numeric value as |x|.
7864
+ 1. Assert: [$Type$](|x|) is Number.
7865
+ 1. Return the result of [=converted to an ECMAScript value|converting=] |x| to |T|.
7866
+ </div>
7867
+
7771
7868
7772
7869
<h4 id="es-DOMString">DOMString</h4>
7773
7870
@@ -8795,23 +8892,33 @@ that correspond to the union’s [=member types=].
8795
8892
1. If |types| includes {{object}}, then return the IDL value
8796
8893
that is a reference to the object |V|.
8797
8894
1. If <a abstract-op>Type</a>(|V|) is Boolean, then:
8798
- 1. If |types| includes a {{boolean}},
8895
+ 1. If |types| includes {{boolean}},
8799
8896
then return the result of [=converted to an IDL value|converting=]
8800
8897
|V| to {{boolean}}.
8801
8898
1. If <a abstract-op>Type</a>(|V|) is Number, then:
8802
8899
1. If |types| includes a [=numeric type=],
8803
8900
then return the result of [=converted to an IDL value|converting=]
8804
8901
|V| to that [=numeric type=].
8902
+ 1. If <a abstract-op>Type</a>(|V|) is BigInt, then:
8903
+ 1. If |types| includes {{bigint}},
8904
+ then return the result of [=converted to an IDL value|converting=]
8905
+ |V| to {{bigint}}
8805
8906
1. If |types| includes a [=string type=],
8806
8907
then return the result of
8807
8908
[=converted to an IDL value|converting=]
8808
8909
|V| to that type.
8910
+ 1. If |types| includes a [=numeric type=] and {{bigint}},
8911
+ then return the result of [=converted to a numeric type or bigint|converting=]
8912
+ |V| to either that [=numeric type=] or {{bigint}}.
8809
8913
1. If |types| includes a [=numeric type=],
8810
8914
then return the result of [=converted to an IDL value|converting=]
8811
8915
|V| to that [=numeric type=].
8812
- 1. If |types| includes a {{boolean}},
8916
+ 1. If |types| includes {{boolean}},
8813
8917
then return the result of [=converted to an IDL value|converting=]
8814
8918
|V| to {{boolean}}.
8919
+ 1. If |types| includes {{bigint}},
8920
+ then return the result of [=converted to an IDL value|converting=]
8921
+ |V| to {{bigint}}.
8815
8922
1. [=ECMAScript/Throw=] a {{ECMAScript/TypeError}}.
8816
8923
</div>
8817
8924
@@ -11045,6 +11152,16 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
11045
11152
11046
11153
then remove from |S| all other entries.
11047
11154
11155
+ 1. Otherwise: if <a abstract-op>Type</a>(|V|) is BigInt
11156
+ and there is an entry in |S| that has one of the following types at position |i| of its type list,
11157
+ * {{bigint}}
11158
+ * a [=nullable type|nullable=] {{bigint}}
11159
+ * an [=annotated type=] whose [=annotated types/inner type=] is one of the above types
11160
+ * a [=union type=], [=nullable type|nullable=] union type, or [=annotated type|annotated=] union type
11161
+ that has one of the above types in its [=flattened member types=]
11162
+
11163
+ then remove from |S| all other entries.
11164
+
11048
11165
1. Otherwise: if there is an entry in |S| that has one of the following types at position |i| of its type list,
11049
11166
* a [=string type=]
11050
11167
* a [=nullable type|nullable=] version of any of the above types
@@ -11072,6 +11189,15 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
11072
11189
11073
11190
then remove from |S| all other entries.
11074
11191
11192
+ 1. Otherwise: if there is an entry in |S| that has one of the following types at position |i| of its type list,
11193
+ * {{bigint}}
11194
+ * a [=nullable type|nullable=] {{bigint}}
11195
+ * an [=annotated type=] whose [=annotated types/inner type=] is one of the above types
11196
+ * a [=union type=], [=nullable type|nullable=] union type, or [=annotated type|annotated=] union type
11197
+ that has one of the above types in its [=flattened member types=]
11198
+
11199
+ then remove from |S| all other entries.
11200
+
11075
11201
1. Otherwise: if there is an entry in |S| that has {{any}} at position |i|
11076
11202
of its type list, then remove from |S| all other entries.
11077
11203
1. Otherwise: [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
0 commit comments