Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect properties in :string result #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3253,7 +3253,7 @@
<var>opts</var>: an Object,
<var>funcCtx</var>: an Object,
): an ECMAScript value
</a></li><li><span class="item-toggle">+</span><a href="#sec-getmessagefunctions" title="GetMessageFunctions ( userFunctions )"><span class="secnum">1.5.4</span> GetMessageFunctions ( <var>userFunctions</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messageformat-numberfunctions" title="MessageFormat Number Functions"><span class="secnum">1.5.4.1</span> MessageFormat Number Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-stringfunctions" title="MessageFormat String Functions"><span class="secnum">1.5.4.2</span> MessageFormat String Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-datetimefunctions" title="MessageFormat DateTime Functions"><span class="secnum">1.5.4.3</span> MessageFormat DateTime Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-datefunctions" title="MessageFormat Date Functions"><span class="secnum">1.5.4.4</span> MessageFormat Date Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-timefunctions" title="MessageFormat Time Functions"><span class="secnum">1.5.4.5</span> MessageFormat Time Functions</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-createmessageformatcontext" title="CreateMessageFormatContext ( mf, values, onError )"><span class="secnum">1.5.5</span> CreateMessageFormatContext ( <var>mf</var>, <var>values</var>, <var>onError</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messagecontextrecord" title="MessageFormatContext Records"><span class="secnum">1.5.5.1</span> MessageFormatContext Records</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-resolvemessage" title="ResolveMessage ( ctx )"><span class="secnum">1.5.6</span> ResolveMessage ( <var>ctx</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-selectpattern" title="SelectPattern ( ctx )"><span class="secnum">1.5.6.1</span> SelectPattern ( <var>ctx</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-selectvariant" title="SelectVariant ( ctx, selectors, variants )"><span class="secnum">1.5.6.2</span> SelectVariant ( <var>ctx</var>, <var>selectors</var>, <var>variants</var> )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-resolveexpression" title="ResolveExpression ( ctx, expression )"><span class="secnum">1.5.7</span> ResolveExpression ( <var>ctx</var>, <var>expression</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-resolvefunction" title="ResolveFunction ( ctx, source, resArg, annotation )"><span class="secnum">1.5.7.1</span> ResolveFunction ( <var>ctx</var>, <var>source</var>, <var>resArg</var>, <var>annotation</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-resolveunknown" title="ResolveUnknown ( source, value )"><span class="secnum">1.5.7.2</span> ResolveUnknown ( <var>source</var>, <var>value</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-formatmarkuppart" title="FormatMarkupPart ( ctx, markup )"><span class="secnum">1.5.8</span> FormatMarkupPart ( <var>ctx</var>, <var>markup</var> )</a></li><li><span class="item-toggle">+</span><a href="#sec-getsource" title="GetSource ( ctx, value )"><span class="secnum">1.5.9</span> GetSource ( <var>ctx</var>, <var>value</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messagevaluesource" title="MessageValueSource ( mv )"><span class="secnum">1.5.9.1</span> MessageValueSource ( <var>mv</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-handlemessageformaterror" title="HandleMessageFormatError ( ctx, completionRecord )"><span class="secnum">1.5.10</span> HandleMessageFormatError ( <var>ctx</var>, <var>completionRecord</var> )</a></li><li><span class="item-toggle">+</span><a href="#sec-resolvefallback" title="ResolveFallback ( source )"><span class="secnum">1.5.11</span> ResolveFallback ( <var>source</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messagefallbackpart" title="MessageFallbackPart ( source )"><span class="secnum">1.5.11.1</span> MessageFallbackPart ( <var>source</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-messagefallbackstring" title="MessageFallbackString ( source )"><span class="secnum">1.5.11.2</span> MessageFallbackString ( <var>source</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-resolvevalue" title="ResolveValue ( ctx, value )"><span class="secnum">1.5.12</span> ResolveValue ( <var>ctx</var>, <var>value</var> )</a></li></ol></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / July 25, 2024</h1><h1 class="title">Intl.MessageFormat</h1>
</a></li><li><span class="item-toggle">+</span><a href="#sec-getmessagefunctions" title="GetMessageFunctions ( userFunctions )"><span class="secnum">1.5.4</span> GetMessageFunctions ( <var>userFunctions</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messageformat-numberfunctions" title="MessageFormat Number Functions"><span class="secnum">1.5.4.1</span> MessageFormat Number Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-stringfunctions" title="MessageFormat String Functions"><span class="secnum">1.5.4.2</span> MessageFormat String Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-datetimefunctions" title="MessageFormat DateTime Functions"><span class="secnum">1.5.4.3</span> MessageFormat DateTime Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-datefunctions" title="MessageFormat Date Functions"><span class="secnum">1.5.4.4</span> MessageFormat Date Functions</a></li><li><span class="item-toggle-none"></span><a href="#sec-messageformat-timefunctions" title="MessageFormat Time Functions"><span class="secnum">1.5.4.5</span> MessageFormat Time Functions</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-createmessageformatcontext" title="CreateMessageFormatContext ( mf, values, onError )"><span class="secnum">1.5.5</span> CreateMessageFormatContext ( <var>mf</var>, <var>values</var>, <var>onError</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messagecontextrecord" title="MessageFormatContext Records"><span class="secnum">1.5.5.1</span> MessageFormatContext Records</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-resolvemessage" title="ResolveMessage ( ctx )"><span class="secnum">1.5.6</span> ResolveMessage ( <var>ctx</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-selectpattern" title="SelectPattern ( ctx )"><span class="secnum">1.5.6.1</span> SelectPattern ( <var>ctx</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-selectvariant" title="SelectVariant ( ctx, selectors, variants )"><span class="secnum">1.5.6.2</span> SelectVariant ( <var>ctx</var>, <var>selectors</var>, <var>variants</var> )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-resolveexpression" title="ResolveExpression ( ctx, expression )"><span class="secnum">1.5.7</span> ResolveExpression ( <var>ctx</var>, <var>expression</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-resolvefunction" title="ResolveFunction ( ctx, source, resArg, annotation )"><span class="secnum">1.5.7.1</span> ResolveFunction ( <var>ctx</var>, <var>source</var>, <var>resArg</var>, <var>annotation</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-resolveunknown" title="ResolveUnknown ( source, value )"><span class="secnum">1.5.7.2</span> ResolveUnknown ( <var>source</var>, <var>value</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-formatmarkuppart" title="FormatMarkupPart ( ctx, markup )"><span class="secnum">1.5.8</span> FormatMarkupPart ( <var>ctx</var>, <var>markup</var> )</a></li><li><span class="item-toggle">+</span><a href="#sec-getsource" title="GetSource ( ctx, value )"><span class="secnum">1.5.9</span> GetSource ( <var>ctx</var>, <var>value</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messagevaluesource" title="MessageValueSource ( mv )"><span class="secnum">1.5.9.1</span> MessageValueSource ( <var>mv</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-handlemessageformaterror" title="HandleMessageFormatError ( ctx, completionRecord )"><span class="secnum">1.5.10</span> HandleMessageFormatError ( <var>ctx</var>, <var>completionRecord</var> )</a></li><li><span class="item-toggle">+</span><a href="#sec-resolvefallback" title="ResolveFallback ( source )"><span class="secnum">1.5.11</span> ResolveFallback ( <var>source</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-messagefallbackpart" title="MessageFallbackPart ( source )"><span class="secnum">1.5.11.1</span> MessageFallbackPart ( <var>source</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-messagefallbackstring" title="MessageFallbackString ( source )"><span class="secnum">1.5.11.2</span> MessageFallbackString ( <var>source</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-resolvevalue" title="ResolveValue ( ctx, value )"><span class="secnum">1.5.12</span> ResolveValue ( <var>ctx</var>, <var>value</var> )</a></li></ol></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / July 26, 2024</h1><h1 class="title">Intl.MessageFormat</h1>

<emu-clause id="messageformat-objects">
<h1><span class="secnum">1</span> MessageFormat Objects</h1>
Expand Down Expand Up @@ -3511,7 +3511,7 @@ <h1><span class="secnum">1.5.4.2</span> MessageFormat String Functions</h1>
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:
</p>

<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>
<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>

<p>
The <emu-val>"length"</emu-val> property of a MessageFormat string function is <emu-val>3</emu-val>.
Expand Down
11 changes: 5 additions & 6 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,15 @@ contributors: Eemeli Aro

<emu-alg>
1. Let _str_ be ? ToString(_input_).
1. Let _source_ be ! Get(_funcCtx_, *"source"*).
1. Let _locale_ be ! Get(_funcCtx_, *"locale"*).
1. Let _locale0_ be ! Get(_locale_, *"0"*).
1. Let _selectKeyClosure_ be a new Abstract Closure with parameters (_keys_) that captures _str_ and performs the following steps when called:
1. Let _keyList_ be ? CreateListFromArrayLike(_keys_, « String »).
1. If _keyList_ contains _str_, return _str_.
1. Else, return *null*.
1. Let _selectKey_ be CreateBuiltinFunction(_selectKeyClosure_, *1*, *"selectKey"*, « »).
1. Let _toPartsClosure_ be a new Abstract Closure with no parameters that captures _funcCtx_ and _str_ and performs the following steps when called:
1. Let _source_ be ! Get(_funcCtx_, *"source"*).
1. Let _locale_ be ! Get(_funcCtx_, *"locale"*).
1. Let _locale0_ be ! Get(_locale_, *"0"*).
1. Let _result_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"type"*, *"string"*).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"source"*, _source_).
Expand All @@ -539,10 +539,9 @@ contributors: Eemeli Aro
1. Let _toString_ be CreateBuiltinFunction(_toStringClosure_, *0*, *"toString"*, « »).
1. Let _valueOf_ be CreateBuiltinFunction(_toStringClosure_, *0*, *"valueOf"*, « »).
1. Let _mv_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"type"*, *"number"*).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"type"*, *"string"*).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"source"*, _source_).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"locale"*, _numberFormat_.[[Locale]]).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"options"*, _opts_).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"locale"*, _locale0_).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"selectKey"*, _selectKey_).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"toParts"*, _toParts_).
1. Perform ! CreateDataPropertyOrThrow(_mv_, *"toString"*, _toString_).
Expand Down