[Webkit-unassigned] [Bug 202139] Object spread ({ ... } syntax): object key order is modified

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Sep 24 18:41:36 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=202139

Ross Kirsling <ross.kirsling at sony.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ross.kirsling at sony.com

--- Comment #1 from Ross Kirsling <ross.kirsling at sony.com> ---
Spec-wise, it apparently all depends on *how* you get the keys out of the object.

Object.{keys, values, entries} and JSON.stringify apparently use EnumerableOwnPropertyNames which ultimately states "[t]he mechanics and order of enumerating the properties is not specified".
(https://tc39.es/ecma262/#sec-enumerableownpropertynames)

That said, Reflect.ownKeys uses OrdinaryOwnPropertyKeys which states that string keys should be in "ascending chronological order of property creation".
(https://tc39.es/ecma262/#sec-ordinaryownpropertykeys)

So we definitely have a bug with the latter:
  Reflect.ownKeys(Object.assign({}, { a: 1, b: 100, c: 3 }, { b: 3 }))
  > a,b,c
  Reflect.ownKeys({ ...{ a: 1, b: 100, c: 3 }, ...{ b: 3 } })
  > a,c,b

And fixing that may result in a "fix" for the behavior you mentioned too.

This would certainly be desirable, because there is in fact a proposal aiming to (partially) specify the order of EnumerableOwnPropertyNames which is about to reach stage 3 (https://github.com/tc39/proposal-for-in-order/).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190925/caabd653/attachment-0001.html>


More information about the webkit-unassigned mailing list