Jacek Caban : jscript: Allow trailing comma in object literals.
Alexandre Julliard
julliard at winehq.org
Tue Oct 16 15:53:07 CDT 2018
Module: wine
Branch: master
Commit: 4cabe3612fa3bd1188f17b244c635c950a831bbe
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4cabe3612fa3bd1188f17b244c635c950a831bbe
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Oct 16 17:22:03 2018 +0200
jscript: Allow trailing comma in object literals.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/parser.y | 8 ++++++++
dlls/jscript/tests/lang.js | 14 ++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index a40b813..0bb8856 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -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
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index badb6a8..1cd5668 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -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;
More information about the wine-cvs
mailing list