Fix the initialization of let/const patterns when block context is needed. (#3320)

Also some code cuplication is removed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-11-15 14:38:14 +01:00
committed by Dániel Bátyai
parent 8eda9bc1c3
commit fca0c94002
8 changed files with 297 additions and 205 deletions
+25
View File
@@ -58,6 +58,8 @@ checkSyntax ("[super] = []");
checkSyntax ("[this] = []");
checkSyntax ("[()] = []");
checkSyntax ("try { let [$] = $;");
checkSyntax ("let a, [ b.c ] = [6];");
checkSyntax ("let [(a)] = [1]");
mustThrow ("var [a] = 4");
mustThrow ("var [a] = 5");
@@ -222,3 +224,26 @@ mustThrow ("var [a] = { [Symbol.iterator] () { return { next () { return { get d
assert (a === 1);
assert (b === 2);
}) ();
// Force the creation of lexical environment I.
(function () {
const [a] = [1];
eval();
assert (a === 1);
}) ();
// Force the creation of lexical environment II.
(function () {
let [a] = [1];
eval();
assert (a === 1);
}) ();
// Check the parsing of AssignmentElement
(function () {
var a = 6;
[((a))] = [7];
assert (a === 7);
}) ();