Review Request: kjs: Allow keywords as object propertynames

Review request for kdelibs.

For kjs,

Allow keywords as object propterynames, like:

var tokenCodes = {};
tokenCodes.null = 0;
tokenCodes.true = 1;

This fixes 24 ecmascript262 tests
7.6.1-2-1 to 7.6.1-2-12
7.6.1-6-1 to 7.6.1-6-12

kjs/lexer.cpp e89de5f

Diff: <a href="" title=""></a>

tested with ecmascript262 (until konq hits the freeze bug), no new fails


Bernd Buschinski


Re: Review Request: kjs: Allow keywords as object propertynames

By Maksim Orlovich at 02/27/2012 - 22:04

Thanks for the patch.

I don't think that this is a good approach. Spec-wise, what permits
keywords to be used in a few spots is not just the production
MemberExpression ::= MemberExpression . IdentifierName and likewise
for CallExpression (where IdentifierName matches both our
IdentifierOrKeyword and our Identifier) but also the PropertyName ::=
IdentifierName production, which occurs in other contexts -- in
particular object literals. And you can't say that a reserved word is
an identifier after a {, but
{ if : 42 } is legal! I think it would be both more general and
cleaner to add a new non-terminal to our syntactic grammar
corresponding to IdentifierName and then use it in spots where the
ES5.1 grammar calls for it.

Hope this helps,

On 2/23/12, Bernd Buschinski <b. ... at googlemail dot com> wrote: