Index: src/parsing/preparser.cc |
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc |
index 1dae5e9b6658e85b1681f984c5fd4f0c6b7e02b1..95c12c698545c70e7a763d42c16a238f3d33106c 100644 |
--- a/src/parsing/preparser.cc |
+++ b/src/parsing/preparser.cc |
@@ -131,19 +131,19 @@ PreParser::PreParseResult PreParser::PreParseFunction( |
formals_end_position, CHECK_OK_VALUE(kPreParseSuccess)); |
has_duplicate_parameters = |
!classifier()->is_valid_formal_parameter_list_without_duplicates(); |
- |
- if (track_unresolved_variables_) { |
- function_scope->DeclareVariableName( |
- ast_value_factory()->arguments_string(), VAR); |
- function_scope->DeclareVariableName(ast_value_factory()->this_string(), |
- VAR); |
- } |
} |
Expect(Token::LBRACE, CHECK_OK_VALUE(kPreParseSuccess)); |
LazyParsingResult result = ParseStatementListAndLogFunction( |
&formals, has_duplicate_parameters, may_abort, ok); |
+ if (!IsArrowFunction(kind) && track_unresolved_variables_) { |
+ // Declare arguments after parsing the function since lexical 'arguments' |
+ // masks the arguments object. Declare arguments before declaring the |
+ // function var since the arguments object masks 'function arguments'. |
+ function_scope->DeclareArguments(ast_value_factory()); |
+ } |
+ |
if (is_sloppy(function_scope->language_mode())) { |
function_scope->HoistSloppyBlockFunctions(nullptr); |
} |
@@ -209,8 +209,6 @@ PreParser::Expression PreParser::ParseFunctionLiteral( |
runtime_call_stats_, |
counters[track_unresolved_variables_][parsing_on_main_thread_]); |
- // Parse function body. |
- PreParserStatementList body; |
DeclarationScope* function_scope = NewFunctionScope(kind); |
function_scope->SetLanguageMode(language_mode); |
FunctionState function_state(&function_state_, &scope_state_, function_scope); |
@@ -230,8 +228,13 @@ PreParser::Expression PreParser::ParseFunctionLiteral( |
formals_end_position, CHECK_OK); |
Expect(Token::LBRACE, CHECK_OK); |
- ParseStatementList(body, Token::RBRACE, CHECK_OK); |
- Expect(Token::RBRACE, CHECK_OK); |
+ |
+ // Parse function body. |
+ PreParserStatementList body; |
+ int pos = function_token_pos == kNoSourcePosition ? peek_position() |
+ : function_token_pos; |
+ ParseFunctionBody(body, function_name, pos, formals, kind, function_type, |
+ CHECK_OK); |
// Parsing the body may change the language mode in our scope. |
language_mode = function_scope->language_mode(); |
@@ -252,7 +255,6 @@ PreParser::Expression PreParser::ParseFunctionLiteral( |
if (is_strict(language_mode)) { |
CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); |
} |
- function_scope->set_end_position(end_position); |
if (FLAG_trace_preparse) { |
PrintF(" [%s]: %i-%i\n", |