Skip to content

Commit 101996c

Browse files
authored
Fix incorrect properties in :string result (#68)
1 parent 00e45e3 commit 101996c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3511,7 +3511,7 @@ <h1><span class="secnum">1.5.4.2</span> MessageFormat String Functions</h1>
35113511
When a MessageFormat string function is called with arguments <var>funcCtx</var> (an Object), <var>options</var> (an Object), and <var>input</var> (an ECMAScript language value), the following steps are taken:
35123512
</p>
35133513
3514-
<emu-alg><ol><li>Let <var>str</var> be ?&nbsp;ToString(<var>input</var>).</li><li>Let <var>selectKeyClosure</var> be a new Abstract Closure with parameters (<var>keys</var>) that captures <var>str</var> and performs the following steps when called:<ol><li>Let <var>keyList</var> be ?&nbsp;CreateListFromArrayLike(<var>keys</var>, « String&nbsp;»).</li><li>If <var>keyList</var> contains <var>str</var>, return <var>str</var>.</li><li>Else, return <emu-val>null</emu-val>.</li></ol></li><li>Let <var>selectKey</var> be CreateBuiltinFunction(<var>selectKeyClosure</var>, <emu-val>1</emu-val>, <emu-val>"selectKey"</emu-val>, «&nbsp;»).</li><li>Let <var>toPartsClosure</var> be a new Abstract Closure with no parameters that captures <var>funcCtx</var> and <var>str</var> and performs the following steps when called:<ol><li>Let <var>source</var> be !&nbsp;Get(<var>funcCtx</var>, <emu-val>"source"</emu-val>).</li><li>Let <var>locale</var> be !&nbsp;Get(<var>funcCtx</var>, <emu-val>"locale"</emu-val>).</li><li>Let <var>locale0</var> be !&nbsp;Get(<var>locale</var>, <emu-val>"0"</emu-val>).</li><li>Let <var>result</var> be OrdinaryObjectCreate(%Object.prototype%).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"type"</emu-val>, <emu-val>"string"</emu-val>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"source"</emu-val>, <var>source</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"locale"</emu-val>, <var>locale0</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"value"</emu-val>, <var>str</var>).</li><li>Return CreateArrayFromList(« <var>result</var>&nbsp;»).</li></ol></li><li>Let <var>toParts</var> be CreateBuiltinFunction(<var>toPartsClosure</var>, <emu-val>0</emu-val>, <emu-val>"toParts"</emu-val>, «&nbsp;»).</li><li>Let <var>toStringClosure</var> be a new Abstract Closure with no parameters that captures <var>str</var> and performs the following steps when called:<ol><li>Return <var>str</var>.</li></ol></li><li>Let <var>toString</var> be CreateBuiltinFunction(<var>toStringClosure</var>, <emu-val>0</emu-val>, <emu-val>"toString"</emu-val>, «&nbsp;»).</li><li>Let <var>valueOf</var> be CreateBuiltinFunction(<var>toStringClosure</var>, <emu-val>0</emu-val>, <emu-val>"valueOf"</emu-val>, «&nbsp;»).</li><li>Let <var>mv</var> be OrdinaryObjectCreate(%Object.prototype%).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"type"</emu-val>, <emu-val>"number"</emu-val>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"source"</emu-val>, <var>source</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"locale"</emu-val>, <var>numberFormat</var>.<var class="field">[[Locale]]</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"options"</emu-val>, <var>opts</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"selectKey"</emu-val>, <var>selectKey</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"toParts"</emu-val>, <var>toParts</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"toString"</emu-val>, <var>toString</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"valueOf"</emu-val>, <var>valueOf</var>).</li><li>Return <var>mv</var>.</li></ol></emu-alg>
3514+
<emu-alg><ol><li>Let <var>str</var> be ?&nbsp;ToString(<var>input</var>).</li><li>Let <var>source</var> be !&nbsp;Get(<var>funcCtx</var>, <emu-val>"source"</emu-val>).</li><li>Let <var>locale</var> be !&nbsp;Get(<var>funcCtx</var>, <emu-val>"locale"</emu-val>).</li><li>Let <var>locale0</var> be !&nbsp;Get(<var>locale</var>, <emu-val>"0"</emu-val>).</li><li>Let <var>selectKeyClosure</var> be a new Abstract Closure with parameters (<var>keys</var>) that captures <var>str</var> and performs the following steps when called:<ol><li>Let <var>keyList</var> be ?&nbsp;CreateListFromArrayLike(<var>keys</var>, « String&nbsp;»).</li><li>If <var>keyList</var> contains <var>str</var>, return <var>str</var>.</li><li>Else, return <emu-val>null</emu-val>.</li></ol></li><li>Let <var>selectKey</var> be CreateBuiltinFunction(<var>selectKeyClosure</var>, <emu-val>1</emu-val>, <emu-val>"selectKey"</emu-val>, «&nbsp;»).</li><li>Let <var>toPartsClosure</var> be a new Abstract Closure with no parameters that captures <var>funcCtx</var> and <var>str</var> and performs the following steps when called:<ol><li>Let <var>result</var> be OrdinaryObjectCreate(%Object.prototype%).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"type"</emu-val>, <emu-val>"string"</emu-val>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"source"</emu-val>, <var>source</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"locale"</emu-val>, <var>locale0</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>result</var>, <emu-val>"value"</emu-val>, <var>str</var>).</li><li>Return CreateArrayFromList(« <var>result</var>&nbsp;»).</li></ol></li><li>Let <var>toParts</var> be CreateBuiltinFunction(<var>toPartsClosure</var>, <emu-val>0</emu-val>, <emu-val>"toParts"</emu-val>, «&nbsp;»).</li><li>Let <var>toStringClosure</var> be a new Abstract Closure with no parameters that captures <var>str</var> and performs the following steps when called:<ol><li>Return <var>str</var>.</li></ol></li><li>Let <var>toString</var> be CreateBuiltinFunction(<var>toStringClosure</var>, <emu-val>0</emu-val>, <emu-val>"toString"</emu-val>, «&nbsp;»).</li><li>Let <var>valueOf</var> be CreateBuiltinFunction(<var>toStringClosure</var>, <emu-val>0</emu-val>, <emu-val>"valueOf"</emu-val>, «&nbsp;»).</li><li>Let <var>mv</var> be OrdinaryObjectCreate(%Object.prototype%).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"type"</emu-val>, <emu-val>"string"</emu-val>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"source"</emu-val>, <var>source</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"locale"</emu-val>, <var>locale0</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"selectKey"</emu-val>, <var>selectKey</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"toParts"</emu-val>, <var>toParts</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"toString"</emu-val>, <var>toString</var>).</li><li>Perform !&nbsp;CreateDataPropertyOrThrow(<var>mv</var>, <emu-val>"valueOf"</emu-val>, <var>valueOf</var>).</li><li>Return <var>mv</var>.</li></ol></emu-alg>
35153515
35163516
<p>
35173517
The <emu-val>"length"</emu-val> property of a MessageFormat string function is <emu-val>3</emu-val>.

spec.emu

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,15 @@ contributors: Eemeli Aro
518518

519519
<emu-alg>
520520
1. Let _str_ be ? ToString(_input_).
521+
1. Let _source_ be ! Get(_funcCtx_, *"source"*).
522+
1. Let _locale_ be ! Get(_funcCtx_, *"locale"*).
523+
1. Let _locale0_ be ! Get(_locale_, *"0"*).
521524
1. Let _selectKeyClosure_ be a new Abstract Closure with parameters (_keys_) that captures _str_ and performs the following steps when called:
522525
1. Let _keyList_ be ? CreateListFromArrayLike(_keys_, « String »).
523526
1. If _keyList_ contains _str_, return _str_.
524527
1. Else, return *null*.
525528
1. Let _selectKey_ be CreateBuiltinFunction(_selectKeyClosure_, *1*, *"selectKey"*, « »).
526529
1. Let _toPartsClosure_ be a new Abstract Closure with no parameters that captures _funcCtx_ and _str_ and performs the following steps when called:
527-
1. Let _source_ be ! Get(_funcCtx_, *"source"*).
528-
1. Let _locale_ be ! Get(_funcCtx_, *"locale"*).
529-
1. Let _locale0_ be ! Get(_locale_, *"0"*).
530530
1. Let _result_ be OrdinaryObjectCreate(%Object.prototype%).
531531
1. Perform ! CreateDataPropertyOrThrow(_result_, *"type"*, *"string"*).
532532
1. Perform ! CreateDataPropertyOrThrow(_result_, *"source"*, _source_).
@@ -539,10 +539,9 @@ contributors: Eemeli Aro
539539
1. Let _toString_ be CreateBuiltinFunction(_toStringClosure_, *0*, *"toString"*, « »).
540540
1. Let _valueOf_ be CreateBuiltinFunction(_toStringClosure_, *0*, *"valueOf"*, « »).
541541
1. Let _mv_ be OrdinaryObjectCreate(%Object.prototype%).
542-
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"type"*, *"number"*).
542+
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"type"*, *"string"*).
543543
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"source"*, _source_).
544-
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"locale"*, _numberFormat_.[[Locale]]).
545-
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"options"*, _opts_).
544+
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"locale"*, _locale0_).
546545
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"selectKey"*, _selectKey_).
547546
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"toParts"*, _toParts_).
548547
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"toString"*, _toString_).

0 commit comments

Comments
 (0)