Improve eval call parsing. (#3330)

Eval calls are recognised when the eval identifier is encapsulated in brackets.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2019-11-19 15:55:53 +01:00
committed by Robert Fancsik
parent a1189cfb62
commit 70566a52fb
5 changed files with 270 additions and 22 deletions
+26
View File
@@ -137,7 +137,9 @@ default:
must_throw ("var x => x;");
must_throw ("(()) => 0");
must_throw ("((x)) => 0");
must_throw ("(((x))) => 0");
must_throw ("(x,) => 0");
must_throw ("(x==6) => 0");
must_throw ("(x y) => 0");
must_throw ("(x,y,) => 0");
must_throw ("x\n => 0");
@@ -148,3 +150,27 @@ must_throw_strict ("(package) => 0");
must_throw_strict ("(package) => { return 5 }");
must_throw_strict ("(x,x,x) => 0");
must_throw_strict ("(x,x,x) => { }");
var f = (a) => 1;
assert(f() === 1);
var f = (a => 2);
assert(f() === 2);
var f = ((((a => ((3))))));
assert(f() === 3);
var f = (((a) => 4));
assert(f() === 4);
var f = (a,b) => 5;
assert(f() === 5);
var f = (((a,b) => 6));
assert(f() === 6);
var f = ((a,b) => x => (a) => 7);
assert(f()()() === 7);
var f = (((a=1,b=2) => ((x => (((a) => 8))))));
assert(f()()() === 8);
+30
View File
@@ -122,3 +122,33 @@ catch(e)
code = 'eval("(function (){})")';
code = "eval ('" + code + "')";
eval (code);
// Eval enclosed in brackets is still an eval.
var p1 = 0;
function f3() {
var p1 = 5;
(eval)("assert(p1 === 5)");
}
f3();
function f4() {
var p1 = 6;
((eval))("assert(p1 === 6)");
}
f4();
function f5() {
var p1 = 7;
(((((eval)))("assert(p1 === 7)")));
}
f5();
function f6() {
var p1 = 8;
var e = eval;
e("assert(p1 === 0)");
(((((e)))("assert(p1 === 0)")));
}
f6();