Skip to content

Commit b1d445b

Browse files
Use CopyNameAndLength in Snapshot.wrap (tc39#86)
This uses the `CopyNameAndLength` AO defined in the ShadowRealm proposal to address the unexpected behavior of the `length` property discovered in https://github.com/tc39/test262/pull/3874/files#r1501253279.
1 parent bdd5486 commit b1d445b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

shadowrealm-biblio.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"location":"https://tc39.es/proposal-shadowrealm/","entries":[{"type":"op","aoid":"CopyNameAndLength","refId":"sec-copynameandlength","kind":"abstract operation","signature":{"parameters":[{"name":"_F_","type":{"kind":"opaque","type":"a function object"}},{"name":"_Target_","type":{"kind":"opaque","type":"a function object"}}],"optionalParameters":[{"name":"_prefix_","type":{"kind":"opaque","type":"a String"}},{"name":"_argCount_","type":{"kind":"opaque","type":"a Number"}}],"return":{"kind":"completion","completionType":"mixed","typeOfValueIfNormal":{"kind":"unused"}}},"effects":[]},{"type":"clause","id":"sec-copynameandlength","aoid":"CopyNameAndLength","title":"CopyNameAndLength ( F, Target [ , prefix [ , argCount ] ] )","titleHTML":"CopyNameAndLength ( <var>F</var>, <var>Target</var> [ , <var>prefix</var> [ , <var>argCount</var> ] ] )","number":"3.1.2"}]}

spec.html

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
stage: 1
77
contributors: Chengzhong Wu, Justin Ridgewell
88
</pre>
9+
<emu-biblio href="./shadowrealm-biblio.json"></emu-biblio>
910

1011
<emu-clause id="sec-ecmascript-data-types-and-values">
1112
<h1>ECMAScript Data Types and Values</h1>
@@ -1001,13 +1002,14 @@ <h1>AsyncContext.Snapshot.wrap ( _fn_ )</h1>
10011002
1. Let _result_ be Completion(Call(_fn_, _thisArgument_, _args_)).
10021003
1. AsyncContextSwap(_previousContextMapping_).
10031004
1. Return _result_.
1004-
1. Let _length_ be ? LengthOfArrayLike(_fn_).
1005-
1. Let _name_ be ? Get(_fn_, *"name"*).
1006-
1. If _name_ is not a String, set _name_ to the empty String.
1007-
1. Let _realm_ be the current Realm Record.
1008-
1. Let _prototype_ be _realm_.[[Intrinsics]].[[%Function.prototype%]].
1009-
1. Return CreateBuiltinFunction(_closure_, _length_, _name_, &laquo; &raquo;, _realm_, _prototype_, *"wrapped"*).
1005+
1. Let _wrapped_ be CreateBuiltinFunction(_closure_, *+0*<sub>𝔽</sub>, *""*, &laquo; &raquo;).
1006+
1. Perform ? CopyNameAndLength(_wrapped_, _fn_, *"wrapped"*).
1007+
1. Return _wrapped_.
10101008
</emu-alg>
1009+
1010+
<emu-note type="editor">
1011+
This algorithm uses the CopyNameAndLength AO defined in the ShadowRealm proposal. Since that AO does not depend on the rest of the ShadowRealm proposal, its definition (along with the changes to Function.prototype.bind) could be moved to this proposal if it were to advance stages beyond ShadowRealm.
1012+
</emu-note>
10111013
</emu-clause>
10121014
</emu-clause>
10131015

0 commit comments

Comments
 (0)