ECMA-262 in Lean

Spec issues · defect of the text · docs/spec-issues/33-createintrinsics-async-argument-position.md

33. CreateIntrinsics passes async in prefix's position: every built-in gets a Boolean prefix

Location
§9.3.2 CreateIntrinsics (#sec-createintrinsics), step 2, with §10.3.4 CreateBuiltinFunction (#sec-createbuiltinfunction), its header and steps 3, 7 and 13, §10.2.9 SetFunctionName (#sec-setfunctionname), step 5.a, and the "name" paragraphs of §18 ECMAScript Standard Built-in Objects (#sec-ecmascript-standard-built-in-objects).
Kind
a call outside its parameter types (an argument in the wrong position).
Model erratum
CreateIntrinsicsAsyncArgument, default reading test262; its readings: literal, test262, proposed. Read literally, the run stops at SetFunctionName step 5.a under CreateBuiltinFunction, where async is concatenated as the prefix; the test262 and proposed readings pass prefix as §18 gives it and set [[Async]] from the step's sentence.
Upstream
Checked 2026-11-19: issue #3534 (open, 2025-02), "CreateIntrinsics isn't passing prefix to CreateBuiltinFunction for builtin getters/setters", reports the missing prefix; issue #4046 (open, 2026-10), "Editorial: CreateBuiltinFunction call in CreateIntrinsics passes wrong parameters", reports the argument position. PR #4022 (closed without merging, 2026-10) proposed six arguments and setting [[Async]] afterwards; PR #2833 (open, 2022-07), "Editorial: Specify prefix for non-specific uses of CreateBuiltinFunction", passes prefix last and predates async, which came with PR #2942 (merged 2025-12, commit 7029ed1b2).
On this site
CreateIntrinsicsAsyncArgument on the Errata page (defect of the text; its default: the test262 reading)

Text

CreateIntrinsics, step 2:

All values that are built-in function objects are created by performing CreateBuiltinFunction(steps, length, name, slots, realmRecord, proto, async) where steps is the definition of that function provided by this specification, name is the initial value of the function's "name" property, … and async is true if the function is described as “async” and false otherwise.

CreateBuiltinFunction's header:

CreateBuiltinFunction ( behaviour: an Abstract Closure, a set of algorithm steps, or some other definition of a function's behaviour provided in this specification, length: a non-negative integer or +∞, name: a property key or a Private Name, additionalInternalSlotsList: a List of names of internal slots, optional realm: a Realm Record, optional proto: an Object or null, optional prefix: a String, optional async: a Boolean, ): a built-in function object

and its steps:

3. If async is not present, set async to false.

7. Set func.[[Async]] to async.

13. If prefix is not present, then

a. Perform SetFunctionName(func, name).

14. Else,

a. Perform SetFunctionName(func, name, prefix).

SetFunctionName:

5. If prefix is present, then

a. Let prefixedName be the string-concatenation of prefix, the code unit 0x0020 (SPACE), and name.

Problem

The step passes seven arguments; the seventh parameter is prefix, a String. So every built-in function created by CreateIntrinsics gets prefix false (or true) and no async. CreateBuiltinFunction then calls SetFunctionName with a Boolean prefix, whose step 5.a concatenates a Boolean with Strings, which is not defined; and [[Async]] is false for every built-in, so Array.fromAsync, the one built-in described as "async", runs its steps without AsyncFunctionStart (BuiltinCallOrConstruct, step 10) and its Await has no async function context. The step's intent is clear from its own sentence and from §18: async in its own position, and prefix "get" or "set" for an accessor, which the step does not pass at all. Since async follows prefix, a call that passes async must pass some prefix, so the fix gives prefix an empty case.

Examples

examples/33-createintrinsics-async-argument-position.js (outputs: the recorded runs):

print(Object.getOwnPropertyDescriptor(Map.prototype, "size").get.name);
print(Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get.name);
var p = Array.fromAsync([1, 2]);
print(Object.prototype.toString.call(p));
p.then(function (v) { print("fromAsync fulfils with " + JSON.stringify(v)); });
output
literal text none: creating the realm's first built-in function concatenates a Boolean (SetFunctionName 5.a)
proposed text get size, get flags, [object Promise], fromAsync fulfils with [1,2]
V8, SpiderMonkey, JavaScriptCore get size, get flags, [object Promise], fromAsync fulfils with [1,2]
formal model, literal reading none: the run stops at SetFunctionName 5.a while the realm is created
formal model, test262 and proposed readings get size, get flags, [object Promise], fromAsync fulfils with [1,2]

Proposed wording

--- a/spec.html
+++ b/spec.html
@@ -11854,7 +11854,7 @@
       </dl>
       <emu-alg>
         1. Set _realmRecord_.[[Intrinsics]] to a new Record.
-        1. [declared="steps,name,length,slots,proto,async"] Set fields of _realmRecord_.[[Intrinsics]] with the values listed in <emu-xref href="#table-well-known-intrinsic-objects"></emu-xref>. The field names are the names listed in the “Intrinsic Name” column of the table. The value of each field is a new object value fully and recursively populated with property values as defined by the specification of each object in clauses <emu-xref href="#sec-global-object"></emu-xref> through <emu-xref href="#sec-reflection"></emu-xref>. All object property values are newly created object values. All values that are built-in function objects are created by performing CreateBuiltinFunction(_steps_, _length_, _name_, _slots_, _realmRecord_, _proto_, _async_) where _steps_ is the definition of that function provided by this specification, _name_ is the initial value of the function's *"name"* property, _length_ is the initial value of the function's *"length"* property, _slots_ is a list of the names, if any, of the function's specified internal slots, _proto_ is the specified value of the function's [[Prototype]] internal slot, and _async_ is *true* if the function is described as “async” and *false* otherwise. The creation of the intrinsics and their properties must be ordered to avoid any dependencies upon objects that have not yet been created.
+        1. [declared="steps,name,length,slots,proto,prefix,async"] Set fields of _realmRecord_.[[Intrinsics]] with the values listed in <emu-xref href="#table-well-known-intrinsic-objects"></emu-xref>. The field names are the names listed in the “Intrinsic Name” column of the table. The value of each field is a new object value fully and recursively populated with property values as defined by the specification of each object in clauses <emu-xref href="#sec-global-object"></emu-xref> through <emu-xref href="#sec-reflection"></emu-xref>. All object property values are newly created object values. All values that are built-in function objects are created by performing CreateBuiltinFunction(_steps_, _length_, _name_, _slots_, _realmRecord_, _proto_, _prefix_, _async_) where _steps_ is the definition of that function provided by this specification, _name_ and _prefix_ are as given in <emu-xref href="#sec-ecmascript-standard-built-in-objects"></emu-xref> (_prefix_ is <span class="const">empty</span> for a function that is not a get or set accessor function of a built-in property), _length_ is the initial value of the function's *"length"* property, _slots_ is a list of the names, if any, of the function's specified internal slots, _proto_ is the specified value of the function's [[Prototype]] internal slot, and _async_ is *true* if the function is described as “async” and *false* otherwise. The creation of the intrinsics and their properties must be ordered to avoid any dependencies upon objects that have not yet been created.
         1. Perform AddRestrictedFunctionProperties(_realmRecord_.[[Intrinsics]].[[%Function.prototype%]], _realmRecord_).
         1. Return <span class="const">unused</span>.
       </emu-alg>
@@ -14145,7 +14145,7 @@
           _additionalInternalSlotsList_: a List of names of internal slots,
           optional _realm_: a Realm Record,
           optional _proto_: an Object or *null*,
-          optional _prefix_: a String,
+          optional _prefix_: a String or <span class="const">empty</span>,
           optional _async_: a Boolean,
         ): a built-in function object
       </h1>
@@ -14166,7 +14166,7 @@
         1. Set _func_.[[Realm]] to _realm_.
         1. Set _func_.[[InitialName]] to *null*.
         1. Perform SetFunctionLength(_func_, _length_).
-        1. If _prefix_ is not present, then
+        1. If _prefix_ is not present or _prefix_ is <span class="const">empty</span>, then
           1. Perform SetFunctionName(_func_, _name_).
         1. Else,
           1. Perform SetFunctionName(_func_, _name_, _prefix_).

test262

Every test needs the realm's built-ins. Those that observe the two arguments: built-ins/Array/fromAsync/returns-promise.js and built-ins/Array/fromAsync/asyncitems-null-undefined.js (a rejected promise, not a synchronous throw) need [[Async]] true; built-ins/Map/prototype/size/name.js and the other accessor name.js tests need the "get " prefix.

The program

The example is a Script. Its runs on the engines and on the model: the examples' runs.

Open in the debugger: The specification Open in the debugger: The specification, with CreateIntrinsicsAsyncArgument read as literal text Open in the debugger: The specification, with CreateIntrinsicsAsyncArgument read as proposed reading

Source examples/33-createintrinsics-async-argument-position.js
// CreateIntrinsics step 2 passes _async_ where CreateBuiltinFunction takes _prefix_, and passes no _prefix_.
if (typeof print === "undefined") globalThis.print = console.log;
print(Object.getOwnPropertyDescriptor(Map.prototype, "size").get.name);
print(Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get.name);
var p = Array.fromAsync([1, 2]);
print(Object.prototype.toString.call(p));
p.then(function (v) { print("fromAsync fulfils with " + JSON.stringify(v)); });