Duplicate property names (was Re: @@new)

Mark S. Miller erights at google.com
Thu Jun 19 09:02:05 PDT 2014

Yes. For both strict and sloppy, for both static/literal and
dynamic/computed, duplicate property names/symbols in object literals are
no longer an error. Instead, in left-to-right order, each cause the
equivalent of a [[DefineOwnProperty]] on the new object, so that rightward
definitions silently overwrite conflicting leftward definitions. This
should not result in any change to sloppy literals. It just makes strict
literals, regarding this issue alone, act like sloppy literals.  (Once we
have a way to express that a property is to be initialized to a
non-configurable state, we'll need to revisit this. But that's after ES6.)

Since the object is a new normal object, i.e., not exotic and especially
not a proxy, no one should ever be able to observe the object until its
initialization is complete.

If linters want to warn about statically determined duplicate properties,
that is of course their business, and is fine.

On Thu, Jun 19, 2014 at 7:47 AM, Erik Arvidsson <erik.arvidsson at gmail.com>

> On Wed, Jun 18, 2014 at 12:07 AM, Brendan Eich <brendan at mozilla.org>
> wrote:
>> Domenic Denicola wrote:
>>> Another way of guiding the decision: I don't quite recall where the spec
>>> landed `{ x: 1, ["x"]: 2 }`, but we should probably be consistent with that.
>> *Mark Miller:* I am ok with removing the constraint that duplicate
>> dynamic object properties throw (in strict mode) with the caveat that we
>> also remove the same constraint for duplicate static properties.
>> from http://esdiscuss.org/notes/2014-06-06#rest-properties-
>> and-spread-properties-sebastian-markb-ge-.
> https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-06/jun-6.md#conclusionresolution-3
> - For both strict and sloppy object literals, both computed and static
> properties no longer have any duplicate name checking.
> I would like this the above to be clarified.
> At the f2f we were talking about spread in object literals.
> var a = {x: 1, y: 2};
> var b = {x: 3, ...a};
> However, reading the notes the context is lost and it seems like we are
> suggestion removing the duplicate property check added in ES5 for strict
> mode.
> --
> erik
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140619/f6f3a4e5/attachment.html>

More information about the es-discuss mailing list