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

Normative: Remove ToUint32 from array literal evaluation #1124

Merged
merged 1 commit into from Oct 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 41 additions & 36 deletions spec.html
Expand Up @@ -12637,51 +12637,57 @@ <h2>Syntax</h2>
`...` AssignmentExpression[+In, ?Yield, ?Await]
</emu-grammar>

<emu-clause id="sec-static-semantics-elisionwidth">
<h1>Static Semantics: ElisionWidth</h1>
<emu-clause id="sec-runtime-semantics-arrayaccumulation">
<h1>Runtime Semantics: ArrayAccumulation</h1>
<p>With parameters _array_ and _nextIndex_.</p>
<emu-grammar>Elision : `,`</emu-grammar>
<emu-alg>
1. Return the numeric value 1.
1. Let _len_ be _nextIndex_ + 1.
1. Perform ? Set(_array_, `"length"`, _len_, *true*).
1. NOTE: The above Set throws if _len_ exceeds 2<sup>32</sup>-1.
1. Return _len_.
</emu-alg>
<emu-grammar>Elision : Elision `,`</emu-grammar>
<emu-alg>
1. Let _preceding_ be the ElisionWidth of |Elision|.
1. Return _preceding_ + 1.
1. Return the result of performing ArrayAccumulation for |Elision| with arguments _array_ and _nextIndex_ + 1.
</emu-alg>
</emu-clause>

<emu-clause id="sec-runtime-semantics-arrayaccumulation">
<h1>Runtime Semantics: ArrayAccumulation</h1>
<p>With parameters _array_ and _nextIndex_.</p>
<emu-grammar>ElementList : Elision? AssignmentExpression</emu-grammar>
<emu-alg>
1. Let _padding_ be the ElisionWidth of |Elision|; if |Elision| is not present, use the numeric value zero.
1. If |Elision| is present, then
1. Let _nextIndex_ be the result of performing ArrayAccumulation for |Elision| with arguments _array_ and _nextIndex_.
1. ReturnIfAbrupt(_nextIndex_).
1. Let _initResult_ be the result of evaluating |AssignmentExpression|.
1. Let _initValue_ be ? GetValue(_initResult_).
1. Let _created_ be CreateDataProperty(_array_, ToString(ToUint32(_nextIndex_ + _padding_)), _initValue_).
1. Assert: _created_ is *true*.
1. Return _nextIndex_ + _padding_ + 1.
1. Let _created_ be ! CreateDataPropertyOrThrow(_array_, ! ToString(_nextIndex_), _initValue_).
1. Return _nextIndex_ + 1.
</emu-alg>
<emu-grammar>ElementList : Elision? SpreadElement</emu-grammar>
<emu-alg>
1. Let _padding_ be the ElisionWidth of |Elision|; if |Elision| is not present, use the numeric value zero.
1. Return the result of performing ArrayAccumulation for |SpreadElement| with arguments _array_ and _nextIndex_ + _padding_.
1. If |Elision| is present, then
1. Let _nextIndex_ be the result of performing ArrayAccumulation for |Elision| with arguments _array_ and _nextIndex_.
1. ReturnIfAbrupt(_nextIndex_).
1. Return the result of performing ArrayAccumulation for |SpreadElement| with arguments _array_ and _nextIndex_.
</emu-alg>
<emu-grammar>ElementList : ElementList `,` Elision? AssignmentExpression</emu-grammar>
<emu-alg>
1. Let _postIndex_ be ? ArrayAccumulation of |ElementList| with arguments _array_ and _nextIndex_.
1. Let _padding_ be the ElisionWidth of |Elision|; if |Elision| is not present, use the numeric value zero.
1. Let _nextIndex_ be the result of performing ArrayAccumulation for |ElementList| with arguments _array_ and _nextIndex_.
1. ReturnIfAbrupt(_nextIndex_).
1. If |Elision| is present, then
1. Let _nextIndex_ be the result of performing ArrayAccumulation for |Elision| with arguments _array_ and _nextIndex_.
1. ReturnIfAbrupt(_nextIndex_).
1. Let _initResult_ be the result of evaluating |AssignmentExpression|.
1. Let _initValue_ be ? GetValue(_initResult_).
1. Let _created_ be CreateDataProperty(_array_, ToString(ToUint32(_postIndex_ + _padding_)), _initValue_).
1. Assert: _created_ is *true*.
1. Return _postIndex_ + _padding_ + 1.
1. Let _created_ be ! CreateDataPropertyOrThrow(_array_, ! ToString(_nextIndex_), _initValue_).
1. Return _nextIndex_+1.
</emu-alg>
<emu-grammar>ElementList : ElementList `,` Elision? SpreadElement</emu-grammar>
<emu-alg>
1. Let _postIndex_ be ? ArrayAccumulation of |ElementList| with arguments _array_ and _nextIndex_.
1. Let _padding_ be the ElisionWidth of |Elision|; if |Elision| is not present, use the numeric value zero.
1. Return the result of performing ArrayAccumulation for |SpreadElement| with arguments _array_ and _postIndex_ + _padding_.
1. Let _nextIndex_ be the result of performing ArrayAccumulation for |ElementList| with arguments _array_ and _nextIndex_.
1. ReturnIfAbrupt(_nextIndex_).
1. If |Elision| is present, then
1. Let _nextIndex_ be the result of performing ArrayAccumulation for |Elision| with arguments _array_ and _nextIndex_.
1. ReturnIfAbrupt(_nextIndex_).
1. Return the result of performing ArrayAccumulation for |SpreadElement| with arguments _array_ and _nextIndex_.
</emu-alg>
<emu-grammar>SpreadElement : `...` AssignmentExpression</emu-grammar>
<emu-alg>
Expand All @@ -12692,8 +12698,7 @@ <h1>Runtime Semantics: ArrayAccumulation</h1>
1. Let _next_ be ? IteratorStep(_iteratorRecord_).
1. If _next_ is *false*, return _nextIndex_.
1. Let _nextValue_ be ? IteratorValue(_next_).
1. Let _status_ be CreateDataProperty(_array_, ToString(ToUint32(_nextIndex_)), _nextValue_).
1. Assert: _status_ is *true*.
1. Let _status_ be ! CreateDataPropertyOrThrow(_array_, ! ToString(_nextIndex_), _nextValue_).
1. Set _nextIndex_ to _nextIndex_ + 1.
</emu-alg>
<emu-note>
Expand All @@ -12706,26 +12711,26 @@ <h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ArrayLiteral : `[` Elision? `]`</emu-grammar>
<emu-alg>
1. Let _array_ be ! ArrayCreate(0).
1. Let _pad_ be the ElisionWidth of |Elision|; if |Elision| is not present, use the numeric value zero.
1. Perform Set(_array_, `"length"`, ToUint32(_pad_), *false*).
1. NOTE: The above Set cannot fail because of the nature of the object returned by ArrayCreate.
1. If |Elision| is present, then
1. Let _len_ be the result of performing ArrayAccumulation for |Elision| with arguments _array_ and 0.
1. ReturnIfAbrupt(_len_).
1. Return _array_.
</emu-alg>
<emu-grammar>ArrayLiteral : `[` ElementList `]`</emu-grammar>
<emu-alg>
1. Let _array_ be ! ArrayCreate(0).
1. Let _len_ be ? ArrayAccumulation of |ElementList| with arguments _array_ and 0.
1. Perform Set(_array_, `"length"`, ToUint32(_len_), *false*).
1. NOTE: The above Set cannot fail because of the nature of the object returned by ArrayCreate.
1. Let _len_ be the result of performing ArrayAccumulation for |ElementList| with arguments _array_ and 0.
1. ReturnIfAbrupt(_len_).
1. Return _array_.
</emu-alg>
<emu-grammar>ArrayLiteral : `[` ElementList `,` Elision? `]`</emu-grammar>
<emu-alg>
1. Let _array_ be ! ArrayCreate(0).
1. Let _len_ be ? ArrayAccumulation of |ElementList| with arguments _array_ and 0.
1. Let _padding_ be the ElisionWidth of |Elision|; if |Elision| is not present, use the numeric value zero.
1. Perform Set(_array_, `"length"`, ToUint32(_padding_ + _len_), *false*).
1. NOTE: The above Set cannot fail because of the nature of the object returned by ArrayCreate.
1. Let _nextIndex_ be the result of performing ArrayAccumulation for |ElementList| with arguments _array_ and 0.
1. ReturnIfAbrupt(_nextIndex_).
1. If |Elision| is present, then
1. Let _len_ be the result of performing ArrayAccumulation for |Elision| with arguments _array_ and _nextIndex_.
1. ReturnIfAbrupt(_len_).
1. Return _array_.
</emu-alg>
</emu-clause>
Expand Down