Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gecko object key interpretation specific: a bug or a feature?

0 views
Skip to first unread message

VK

unread,
Oct 24, 2009, 3:20:00 PM10/24/09
to
Having a statement such as:

var obj = {
foo: 'bar',
default: 'default_value'
}

Firefox 3.5.3 creates obj with properties foo and default.

IE reports syntax error "Expected identifier, string or number", same
or similar syntax error occurs on Safari, Chrome and Opera. By placing
default into quotes we are making the code valid for all browsers in
question:

var obj = {
foo: 'bar',
'default': 'default_value'
}

My question is if it is a Gecko bug, a convenience extension or the
proper implementation by ECMA with others being wrong on that?

Ash Berlin

unread,
Oct 24, 2009, 3:59:37 PM10/24/09
to dev-tech-js-engine

This is a spidermonkey 'bug' in the default is in the list of future
reserved words by the ES262 (ECMAScript 3) spec.

Wether its actually a problem or not is another matter of course.


Brendan Eich

unread,
Oct 24, 2009, 9:11:29 PM10/24/09
to
On Oct 24, 12:59 pm, Ash Berlin <ash...@firemirror.com> wrote:
> On 24 Oct 2009, at 20:20, VK wrote:
>
>
>
> > Having a statement such as:
>
> > var obj = {
> > foo: 'bar',
> > default: 'default_value'
> > }
>
> > Firefox 3.5.3 creates obj with properties foo and default.
>
> > IE reports syntax error "Expected identifier, string or number", same
> > or similar syntax error occurs on Safari, Chrome and Opera. By placing
> > default into quotes we are making the code valid for all browsers in
> > question:
>
> > var obj = {
> > foo: 'bar',
> > 'default': 'default_value'
> > }
>
> > My question is if it is a Gecko bug, a convenience extension or the
> > proper implementation by ECMA with others being wrong on that?

Not a bug, yes a convenience, and proper implementation of ES5 (after
ES3.1 and ES4, which both allowed reserved words to be used in
property-name contexts). Also a proper extension to ES3, which allows
such syntactic extensions (see chapter 16).

IE has yet to ship the ES5 JScript implementation I've seen demo'ed at
Ecma TC39 meetings.


> This is a spidermonkey 'bug' in the default is in the list of future  
> reserved words by the ES262 (ECMAScript 3) spec.

No, 'default' is not future-reserved in ES2 or ES3 -- it's used in
switch statements.

/be

VK

unread,
Oct 25, 2009, 1:43:16 PM10/25/09
to
VK wrote:
> > > Having a statement such as:
>
> > > var obj = {
> > > foo: 'bar',
> > > default: 'default_value'
> > > }
>
> > > Firefox 3.5.3 creates obj with properties foo and default.
>
> > > IE reports syntax error "Expected identifier, string or number", same
> > > or similar syntax error occurs on Safari, Chrome and Opera. By placing
> > > default into quotes we are making the code valid for all browsers in
> > > question:
>
> > > var obj = {
> > > foo: 'bar',
> > > 'default': 'default_value'
> > > }
>
> > > My question is if it is a Gecko bug, a convenience extension or the
> > > proper implementation by ECMA with others being wrong on that?

Brendan Eich wrote:
> Not a bug, yes a convenience, and proper implementation of ES5 (after
> ES3.1 and ES4, which both allowed reserved words to be used in
> property-name contexts). Also a proper extension to ES3, which allows
> such syntactic extensions (see chapter 16).
>
> IE has yet to ship the ES5 JScript implementation I've seen demo'ed at
> Ecma TC39 meetings.

Thank you for your clarification.


0 new messages