@@ -167,9 +167,11 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
167167 text: SetFunctionName; url: sec-setfunctionname
168168 text: SetImmutablePrototype; url: sec-set-immutable-prototype
169169 text: SetIntegrityLevel; url: sec-setintegritylevel
170+ text: ToBigInt; url: #sec-tobigint
170171 text: ToBoolean; url: sec-toboolean
171172 text: ToInt32; url: sec-toint32
172173 text: ToNumber; url: sec-tonumber
174+ text: ToNumeric; url: sec-tonumeric
173175 text: ToObject; url: sec-toobject
174176 text: ToPropertyDescriptor; url: sec-topropertydescriptor
175177 text: ToPropertyKey; url: sec-topropertykey
@@ -195,6 +197,7 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
195197 text: array index; url: array-index
196198 text: array iterator object; url: sec-array-iterator-objects
197199 text: built-in function object; url: sec-built-in-function-objects
200+ text: BigInt; url: #sec-ecmascript-language-types-bigint-type
198201 text: callable; for: ECMAScript; url: sec-iscallable
199202 text: Completion Record; url: sec-completion-record-specification-type
200203 text: constructor; url: constructor
@@ -3609,6 +3612,9 @@ the following algorithm returns <i>true</i>.
36093612 </div></th>
36103613 <th><div>
36113614 <span>numeric types</span>
3615+ </div></th>
3616+ <th><div>
3617+ <span>bigint</span>
36123618 </div></th>
36133619 <th><div>
36143620 <span>string types</span>
@@ -3643,11 +3649,26 @@ the following algorithm returns <i>true</i>.
36433649 <td>●</td>
36443650 <td>●</td>
36453651 <td>●</td>
3652+ <td>●</td>
36463653 </tr>
36473654 <tr>
36483655 <th>numeric types</th>
36493656 <td class="belowdiagonal"></td>
36503657 <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>
36513672 <td>●</td>
36523673 <td>●</td>
36533674 <td>●</td>
@@ -3660,6 +3681,7 @@ the following algorithm returns <i>true</i>.
36603681 <th>string types</th>
36613682 <td class="belowdiagonal"></td>
36623683 <td class="belowdiagonal"></td>
3684+ <td class="belowdiagonal"></td>
36633685 <td></td>
36643686 <td>●</td>
36653687 <td>●</td>
@@ -3673,6 +3695,7 @@ the following algorithm returns <i>true</i>.
36733695 <td class="belowdiagonal"></td>
36743696 <td class="belowdiagonal"></td>
36753697 <td class="belowdiagonal"></td>
3698+ <td class="belowdiagonal"></td>
36763699 <td></td>
36773700 <td>●</td>
36783701 <td></td>
@@ -3686,6 +3709,7 @@ the following algorithm returns <i>true</i>.
36863709 <td class="belowdiagonal"></td>
36873710 <td class="belowdiagonal"></td>
36883711 <td class="belowdiagonal"></td>
3712+ <td class="belowdiagonal"></td>
36893713 <td></td>
36903714 <td>●</td>
36913715 <td>●</td>
@@ -3699,6 +3723,7 @@ the following algorithm returns <i>true</i>.
36993723 <td class="belowdiagonal"></td>
37003724 <td class="belowdiagonal"></td>
37013725 <td class="belowdiagonal"></td>
3726+ <td class="belowdiagonal"></td>
37023727 <td>(a)</td>
37033728 <td>●</td>
37043729 <td>●</td>
@@ -3712,6 +3737,7 @@ the following algorithm returns <i>true</i>.
37123737 <td class="belowdiagonal"></td>
37133738 <td class="belowdiagonal"></td>
37143739 <td class="belowdiagonal"></td>
3740+ <td class="belowdiagonal"></td>
37153741 <td></td>
37163742 <td></td>
37173743 <td>●</td>
@@ -3725,6 +3751,7 @@ the following algorithm returns <i>true</i>.
37253751 <td class="belowdiagonal"></td>
37263752 <td class="belowdiagonal"></td>
37273753 <td class="belowdiagonal"></td>
3754+ <td class="belowdiagonal"></td>
37283755 <td></td>
37293756 <td>●</td>
37303757 </tr>
@@ -3738,6 +3765,7 @@ the following algorithm returns <i>true</i>.
37383765 <td class="belowdiagonal"></td>
37393766 <td class="belowdiagonal"></td>
37403767 <td class="belowdiagonal"></td>
3768+ <td class="belowdiagonal"></td>
37413769 <td></td>
37423770 </tr>
37433771 </table>
@@ -3746,6 +3774,10 @@ the following algorithm returns <i>true</i>.
37463774 1. The two identified interface-like types are
37473775 not the same, and no single [=platform object=] implements both
37483776 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>.
37493781 </ol>
37503782
37513783 <div class="example" id="example-distinguishability-diff-types">
@@ -3796,6 +3828,11 @@ for each pair of items the types at index |i| are [=distinguishable=].
37963828The lowest such index is termed the <dfn id="dfn-distinguishing-argument-index" export>distinguishing argument index</dfn>
37973829for the items of the [=effective overload set=] with the given type list size.
37983830
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+
37993836<div class="example">
38003837
38013838 Consider the [=effective overload set=] shown in the previous example.
@@ -5714,7 +5751,7 @@ the [=integer types=],
57145751{{unrestricted double}}.
57155752
57165753The <dfn id="dfn-primitive-type" export>primitive types</dfn> are
5717- {{boolean}} and the [=numeric types=].
5754+ {{bigint}}, {{ boolean}} and the [=numeric types=].
57185755
57195756The <dfn id="dfn-string-type" export>string types</dfn> are
57205757{{DOMString}}, all [=enumeration types=],
@@ -5820,6 +5857,7 @@ type.
58205857 "boolean"
58215858 "byte"
58225859 "octet"
5860+ "bigint"
58235861</pre>
58245862
58255863<pre class="grammar" id="prod-UnrestrictedFloatType">
@@ -6096,6 +6134,16 @@ The [=type name=] of the
60966134{{unrestricted double}} type is "<code>UnrestrictedDouble</code>".
60976135
60986136
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+
60996147<h4 oldids="dom-DOMString" id="idl-DOMString" interface>DOMString</h4>
61006148
61016149The {{DOMString}} type corresponds to
@@ -6557,6 +6605,19 @@ Each pair of [=flattened member types=]
65576605in a [=union type=], <var ignore>T</var> and <var ignore>U</var>,
65586606must be [=distinguishable=].
65596607
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+
65606621[=Union type=] constant values
65616622in IDL are represented in the same way that constant values of their
65626623[=member types=] would be
@@ -7086,6 +7147,7 @@ five forms are allowed.
70867147 "Promise"
70877148 "USVString"
70887149 "any"
7150+ "bigint"
70897151 "boolean"
70907152 "byte"
70917153 "double"
@@ -7339,6 +7401,9 @@ ECMAScript value type.
73397401 1. If <a abstract-op>Type</a>(|V|) is Number, then
73407402 return the result of <a href="#es-to-unrestricted-double">converting</a> |V|
73417403 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}}.
73427407 1. If <a abstract-op>Type</a>(|V|) is String, then
73437408 return the result of <a href="#es-DOMString">converting</a> |V|
73447409 to a {{DOMString}}.
@@ -7768,6 +7833,38 @@ value when its bit pattern is interpreted as an unsigned 64 bit integer.
77687833 {{unrestricted double}} value.
77697834</div>
77707835
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+
77717868
77727869<h4 id="es-DOMString">DOMString</h4>
77737870
@@ -8795,23 +8892,33 @@ that correspond to the union’s [=member types=].
87958892 1. If |types| includes {{object}}, then return the IDL value
87968893 that is a reference to the object |V|.
87978894 1. If <a abstract-op>Type</a>(|V|) is Boolean, then:
8798- 1. If |types| includes a {{boolean}},
8895+ 1. If |types| includes {{boolean}},
87998896 then return the result of [=converted to an IDL value|converting=]
88008897 |V| to {{boolean}}.
88018898 1. If <a abstract-op>Type</a>(|V|) is Number, then:
88028899 1. If |types| includes a [=numeric type=],
88038900 then return the result of [=converted to an IDL value|converting=]
88048901 |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}}
88058906 1. If |types| includes a [=string type=],
88068907 then return the result of
88078908 [=converted to an IDL value|converting=]
88088909 |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}}.
88098913 1. If |types| includes a [=numeric type=],
88108914 then return the result of [=converted to an IDL value|converting=]
88118915 |V| to that [=numeric type=].
8812- 1. If |types| includes a {{boolean}},
8916+ 1. If |types| includes {{boolean}},
88138917 then return the result of [=converted to an IDL value|converting=]
88148918 |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}}.
88158922 1. [=ECMAScript/Throw=] a {{ECMAScript/TypeError}}.
88168923</div>
88178924
@@ -11045,6 +11152,16 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
1104511152
1104611153 then remove from |S| all other entries.
1104711154
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+
1104811165 1. Otherwise: if there is an entry in |S| that has one of the following types at position |i| of its type list,
1104911166 * a [=string type=]
1105011167 * 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]]
1107211189
1107311190 then remove from |S| all other entries.
1107411191
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+
1107511201 1. Otherwise: if there is an entry in |S| that has {{any}} at position |i|
1107611202 of its type list, then remove from |S| all other entries.
1107711203 1. Otherwise: [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
0 commit comments