jscript: Allow trailing comma in object literals.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-10-16 17:22:03 +02:00 committed by Alexandre Julliard
parent adcb216208
commit 4cabe3612f
2 changed files with 22 additions and 0 deletions

View File

@ -778,6 +778,14 @@ ObjectLiteral
: '{' '}' { $$ = new_prop_and_value_expression(ctx, NULL); }
| '{' PropertyNameAndValueList '}'
{ $$ = new_prop_and_value_expression(ctx, $2); }
| '{' PropertyNameAndValueList ',' '}'
{
if(ctx->script->version < 2) {
WARN("Trailing comma in object literal is illegal in legacy mode.\n");
YYABORT;
}
$$ = new_prop_and_value_expression(ctx, $2);
}
/* ECMA-262 3rd Edition 11.1.5 */
PropertyNameAndValueList

View File

@ -480,6 +480,20 @@ ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
ok(obj3.constructor === Object, "unexpected obj3.constructor");
if(invokeVersion >= 2) {
eval("tmp = {prop: 'value',}");
ok(tmp.prop === "value", "tmp.prop = " + tmp.prop);
eval("tmp = {prop: 'value',second:2,}");
ok(tmp.prop === "value", "tmp.prop = " + tmp.prop);
}else {
try {
eval("tmp = {prop: 'value',}");
}catch(e) {
tmp = true;
}
ok(tmp === true, "exception not fired");
}
{
var blockVar = 1;
blockVar = 2;