Bug 522158: Avoid extra warning for duplicated prop names in object initializers. r=waldo

This commit is contained in:
Jim Blandy 2010-08-16 13:05:33 -07:00
parent f585a9f20d
commit 4301b4bb0b
2 changed files with 6 additions and 13 deletions

View File

@ -6028,9 +6028,7 @@ BEGIN_CASE(JSOP_INITMETHOD)
LOAD_ATOM(0, atom);
jsid id = ATOM_TO_JSID(atom);
/* Set the property named by obj[id] to rval. */
if (!CheckRedeclaration(cx, obj, id, JSPROP_INITIALIZER, NULL, NULL))
goto error;
/* No need to check for duplicate property; the compiler already did. */
uintN defineHow = (op == JSOP_INITMETHOD)
? JSDNP_CACHE_RESULT | JSDNP_SET_METHOD
@ -6064,12 +6062,7 @@ BEGIN_CASE(JSOP_INITELEM)
jsid id;
FETCH_ELEMENT_ID(obj, -2, id);
/*
* Check for property redeclaration strict warning (we may be in an object
* initialiser, not an array initialiser).
*/
if (!CheckRedeclaration(cx, obj, id, JSPROP_INITIALIZER, NULL, NULL))
goto error;
/* No need to check for duplicate property; the compiler already did. */
/*
* If rref is a hole, do not call JSObject::defineProperty. In this case,

View File

@ -63,8 +63,8 @@ function test()
try
{
expect = 'TypeError: redeclaration of property a';
var o = {a:4, a:5};
expect = 'SyntaxError: property name a appears more than once in object literal';
eval('({a:4, a:5})');
// syntax warning, need to eval to catch
actual = 'No warning';
}
@ -80,8 +80,8 @@ function test()
try
{
expect = 'TypeError: redeclaration of property 1';
var o1 = {1:1, 1:2};
expect = 'SyntaxError: property name 1 appears more than once in object literal';
eval('({1:1, 1:2})');
// syntax warning, need to eval to catch
actual = 'No warning';
}