Improve new.target handling in case of eval calls (#3517)

Only direct eval calls propagate the "new.target" information.
In any other eval cases the "new.target" invocation is a syntax error.

Added test cases also.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
Péter Gál
2020-01-21 18:01:35 +01:00
committed by Robert Fancsik
parent 05b4bda927
commit 608bc9e5ff
3 changed files with 29 additions and 3 deletions
+24
View File
@@ -91,6 +91,30 @@ function eval_eval_test () {
new eval_eval_test ();
/* new.target is only valid in direct eval */
function eval_test_2 () {
var ev = eval;
try {
ev ("new.target");
assert (false);
} catch (ex) {
assert (ex instanceof SyntaxError);
}
}
new eval_test_2 ();
function eval_test_3 () {
var ev = eval;
try {
eval ("ev ('new.target')");
assert (false);
} catch (ex) {
assert (ex instanceof SyntaxError);
}
}
new eval_test_3 ();
/* test assignment of the "new.target" */
function expect_syntax_error (src)