Skip to content

Commit

Permalink
Use CopyNameAndLength in Snapshot.wrap (#86)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andreubotella authored May 4, 2024
1 parent bdd5486 commit b1d445b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions shadowrealm-biblio.json
Original file line number Diff line number Diff line change
@@ -0,0 +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"}]}
14 changes: 8 additions & 6 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
stage: 1
contributors: Chengzhong Wu, Justin Ridgewell
</pre>
<emu-biblio href="./shadowrealm-biblio.json"></emu-biblio>

<emu-clause id="sec-ecmascript-data-types-and-values">
<h1>ECMAScript Data Types and Values</h1>
Expand Down Expand Up @@ -1001,13 +1002,14 @@ <h1>AsyncContext.Snapshot.wrap ( _fn_ )</h1>
1. Let _result_ be Completion(Call(_fn_, _thisArgument_, _args_)).
1. AsyncContextSwap(_previousContextMapping_).
1. Return _result_.
1. Let _length_ be ? LengthOfArrayLike(_fn_).
1. Let _name_ be ? Get(_fn_, *"name"*).
1. If _name_ is not a String, set _name_ to the empty String.
1. Let _realm_ be the current Realm Record.
1. Let _prototype_ be _realm_.[[Intrinsics]].[[%Function.prototype%]].
1. Return CreateBuiltinFunction(_closure_, _length_, _name_, &laquo; &raquo;, _realm_, _prototype_, *"wrapped"*).
1. Let _wrapped_ be CreateBuiltinFunction(_closure_, *+0*<sub>𝔽</sub>, *""*, &laquo; &raquo;).
1. Perform ? CopyNameAndLength(_wrapped_, _fn_, *"wrapped"*).
1. Return _wrapped_.
</emu-alg>

<emu-note type="editor">
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.
</emu-note>
</emu-clause>
</emu-clause>

Expand Down

0 comments on commit b1d445b

Please sign in to comment.