Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: src/parsing/parser-base.h

Issue 2488493003: [inspector] fix positions for single expression arrow function (Closed)
Patch Set: addressed comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index c349cdd094855420aa2c29ff985eb2777650ce27..02df5cf392f01b432d8f972849d53eddb47d6917 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -2276,7 +2276,7 @@ ParserBase<Impl>::ParseClassFieldForInitializer(bool has_initializer,
initializer_state.expected_property_count(), 0, 0,
FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::kAnonymousExpression, default_eager_compile_hint_,
- initializer_scope->start_position());
+ initializer_scope->start_position(), true);
function_literal->set_is_class_field_initializer(true);
return function_literal;
}
@@ -3910,6 +3910,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
bool is_lazy_top_level_function =
can_preparse && impl()->AllowsLazyParsingWithoutUnresolvedVariables();
bool should_be_used_once_hint = false;
+ bool has_braces = true;
{
FunctionState function_state(&function_state_, &scope_state_,
formal_parameters.scope);
@@ -3972,6 +3973,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
}
} else {
// Single-expression body
+ has_braces = false;
int pos = position();
DCHECK(ReturnExprContext::kInsideValidBlock ==
function_state_->return_expr_context());
@@ -3989,7 +3991,9 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
} else {
ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
- body->Add(factory()->NewReturnStatement(expression, pos), zone());
+ body->Add(
+ factory()->NewReturnStatement(expression, expression->position()),
+ zone());
if (allow_tailcalls() && !is_sloppy(language_mode())) {
// ES6 14.6.1 Static Semantics: IsInTailPosition
impl()->MarkTailPosition(expression);
@@ -4032,7 +4036,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
formal_parameters.num_parameters(), formal_parameters.function_length,
FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::kAnonymousExpression, eager_compile_hint,
- formal_parameters.scope->start_position());
+ formal_parameters.scope->start_position(), has_braces);
function_literal->set_function_token_position(
formal_parameters.scope->start_position());
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698