mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-14 15:37:55 +00:00
Bug 534377 - Object literal duplicate-property checking doesn't work for same property as number and as string. r=jimb
This commit is contained in:
parent
2991bc2ab5
commit
ff43aa766f
@ -8059,6 +8059,19 @@ JSCompiler::primaryExpr(TokenKind tt, JSBool afterDot)
|
||||
attributesMask = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use only string-valued atoms for detecting duplicate
|
||||
* properties so that 1 and "1" properly collide.
|
||||
*/
|
||||
if (ATOM_IS_DOUBLE(atom)) {
|
||||
JSString *str = js_NumberToString(context, pn3->pn_dval);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
atom = js_AtomizeString(context, str, 0);
|
||||
if (!atom)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSAtomListElement *ale = seen.lookup(atom);
|
||||
if (ale) {
|
||||
if (ALE_INDEX(ale) & attributesMask) {
|
||||
|
@ -58,6 +58,26 @@ assertEq(testLenientAndStrict('({6.02214179e23:1, 3.1415926535:1})',
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({ 1: 1, "1": 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({ "1": 1, 1: 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({ 2.5: 1, "2.5": 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({ "2.5": 1, 2.5: 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
true);
|
||||
|
||||
/* Many properties, to exercise JSAtomList's hash-table variant. */
|
||||
assertEq(testLenientAndStrict('({a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:1, k:1, l:1, m:1, n:1, o:1, p:1, q:1, r:1, s:1, t:1, u:1, v:1, w:1, x:1, y:1, z:1})',
|
||||
parsesSuccessfully,
|
||||
|
Loading…
Reference in New Issue
Block a user