Object and array initializers must be parenthesized if expression statements (351625, r=mrbkap).

This commit is contained in:
brendan%mozilla.org 2006-09-07 05:50:23 +00:00
parent c061c7fea4
commit b237fc1549
2 changed files with 7 additions and 3 deletions

View File

@ -2866,7 +2866,11 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
sn = js_GetSrcNote(jp->script, pc);
if (*rval == '[')
--ss->inArrayInit;
todo = Sprint(&ss->sprinter, "%s%s%c",
todo = Sprint(&ss->sprinter,
(pc[1] == JSOP_GROUP &&
(pc[2] == JSOP_POP || pc[2] == JSOP_POPV))
? "(%s%s%c)"
: "%s%s%c",
rval,
(sn && SN_TYPE(sn) == SRC_CONTINUE) ? ", " : "",
(*rval == '[') ? ']' : '}');

View File

@ -211,8 +211,8 @@ OPDEF(JSOP_SETVAR, 87, "setvar", NULL, 3, 1, 1, 3, JOF_QVAR |
OPDEF(JSOP_UINT16, 88, "uint16", NULL, 3, 0, 1, 16, JOF_UINT16)
/* Object and array literal support. */
OPDEF(JSOP_NEWINIT, 89, "newinit", NULL, 1, 2, 1, 15, JOF_BYTE)
OPDEF(JSOP_ENDINIT, 90, "endinit", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_NEWINIT, 89, "newinit", NULL, 1, 2, 1, 0, JOF_BYTE)
OPDEF(JSOP_ENDINIT, 90, "endinit", NULL, 1, 0, 0, 18, JOF_BYTE)
OPDEF(JSOP_INITPROP, 91, "initprop", NULL, 3, 1, 0, 0, JOF_CONST|JOF_PROP|JOF_DETECTING)
OPDEF(JSOP_INITELEM, 92, "initelem", NULL, 1, 2, 0, 0, JOF_BYTE |JOF_ELEM|JOF_DETECTING)
OPDEF(JSOP_DEFSHARP, 93, "defsharp", NULL, 3, 0, 0, 0, JOF_UINT16)