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

[parser] Skipping inner funcs: produce the same scopes / variables for parameters (part 2).

This CL covers simple ("simple") rest param cases.

BUG=v8:5516
R=vogelheim@chromium.org

Change-Id: I254c2eb81d759eb2ea2a3d5e7c46bcdc2ccef707
Reviewed-on: https://chromium-review.googlesource.com/440984Reviewed-by: 's avatarDaniel Vogelheim <vogelheim@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43106}
parent e8422597
......@@ -133,6 +133,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
!classifier()->is_valid_formal_parameter_list_without_duplicates();
}
Expect(Token::LBRACE, CHECK_OK_VALUE(kPreParseSuccess));
DeclarationScope* inner_scope = function_scope;
LazyParsingResult result;
......@@ -143,18 +144,18 @@ PreParser::PreParseResult PreParser::PreParseFunction(
{
BlockState block_state(&scope_state_, inner_scope);
Expect(Token::LBRACE, CHECK_OK_VALUE(kPreParseSuccess));
result = ParseStatementListAndLogFunction(
&formals, has_duplicate_parameters, may_abort, ok);
}
if (!formals.is_simple) {
SetLanguageMode(function_scope, inner_scope->language_mode());
inner_scope->set_end_position(scanner()->location().end_pos);
if (is_sloppy(inner_scope->language_mode())) {
inner_scope->HoistSloppyBlockFunctions(nullptr);
}
if (is_sloppy(function_scope->language_mode())) {
function_scope->HoistSloppyBlockFunctions(nullptr);
if (!formals.is_simple) {
SetLanguageMode(function_scope, inner_scope->language_mode());
inner_scope->set_end_position(scanner()->peek_location().end_pos);
inner_scope->FinalizeBlockScope();
}
if (!IsArrowFunction(kind) && track_unresolved_variables_) {
......
......@@ -20,6 +20,9 @@ TEST(PreParserScopeAnalysis) {
i::HandleScope scope(isolate);
LocalContext env;
// FIXME(marja): Add tests where the test cases are deeper (in a second-level
// inner function or second-level inner arrow function). Remove redundant test
// cases.
const char* prefix = "(function outer() { ";
const char* suffix = " })();";
int prefix_len = Utf8LengthHelper(prefix);
......@@ -299,9 +302,18 @@ TEST(PreParserScopeAnalysis) {
{"var1, var1", "function f1() { var1; }"},
{"var1, var1", "function f1() { var1 = 9; }"},
// FIXME(marja): destructuring parameters, rest parameter, default
// parameters, shadowing parameters, default parameters referring to other
// parameters, arguments parameter, eval in default parameter.
// Rest parameter.
{"...var2", ""},
{"...var2", "var2;"},
{"...var2", "var2 = 9;"},
{"...var2", "function f1() { var2; }"},
{"...var2", "function f1() { var2 = 9; }"},
// FIXME(marja): destructuring parameters, default parameters, shadowing
// parameters, default parameters referring to other parameters, arguments
// parameter, eval in default parameter, params and locals, multiple
// params, many params and rest, destructuring rest, rest with default
// value, locals shadowing params.
};
for (unsigned i = 0; i < arraysize(inners); ++i) {
......
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