Commit 025ea28b authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[parser] Skipping inner funcs: fix sloppy block generators.

PreParser and Parser didn't agree whether a generator in a sloppy block is a
sloppy block function or not, and thus the data generated by PreParser was
inconsistent with what the Parser wanted to restore.

BUG=v8:5516, chromium:760116

Change-Id: I0fd3c267691b8afd63a1336774769caf551c143e
Reviewed-on: https://chromium-review.googlesource.com/642886Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47727}
parent d138f8d7
......@@ -297,6 +297,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
SET_ALLOW(harmony_dynamic_import);
SET_ALLOW(harmony_async_iteration);
SET_ALLOW(harmony_template_escapes);
SET_ALLOW(harmony_restrictive_generators);
#undef SET_ALLOW
}
return reusable_preparser_;
......
......@@ -182,6 +182,14 @@ TEST(PreParserScopeAnalysis) {
{"let var1 = function() { let var2; }"},
{"const var1 = function() { let var2; }"},
{"function *f1() { let var2; }"},
{"let var1 = function *f1() { let var2; }"},
{"let var1 = function*() { let var2; }"},
{"async function f1() { let var2; }"},
{"let var1 = async function f1() { let var2; }"},
{"let var1 = async function() { let var2; }"},
// Redeclarations.
{"var var1; var var1;"},
{"var var1; var var1; var1 = 5;"},
......@@ -451,6 +459,9 @@ TEST(PreParserScopeAnalysis) {
{"if (true) { function f1() {} function f2() { f1(); } }"},
{"if (true) { function *f1() {} }"},
{"if (true) { async function f1() {} }"},
// Simple parameters.
{"var1", ""},
{"var1", "var1;"},
......
......@@ -295,3 +295,22 @@ function TestSkippableFunctionInForOfHeaderAndBody() {
}
TestSkippableFunctionInForOfHeaderAndBody();
(function TestSkippableGeneratorInSloppyBlock() {
var result = 0;
function lazy(ctxt_alloc_param) {
var ctxt_alloc_var = 10;
{
function *skip_me() {
result = ctxt_alloc_param + ctxt_alloc_var;
yield 3;
}
return skip_me;
}
}
// Test that parameters and variables of the outer function get context
// allocated even if we skip the inner function.
assertEquals(3, lazy(9)().next().value);
assertEquals(19, result);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment