Commit 54cc0555 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

Reland "[parser] Remove RETURN_IF* part 16"

Change-Id: I44ac330e093a4cbca4540a1948c9365c08f73914
Reviewed-on: https://chromium-review.googlesource.com/c/1310293Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57183}
parent 5c6e003e
......@@ -449,9 +449,7 @@ class FunctionDeclaration final : public Declaration {
friend class AstNodeFactory;
FunctionDeclaration(VariableProxy* proxy, FunctionLiteral* fun, int pos)
: Declaration(proxy, pos, kFunctionDeclaration), fun_(fun) {
DCHECK_NOT_NULL(fun);
}
: Declaration(proxy, pos, kFunctionDeclaration), fun_(fun) {}
FunctionLiteral* fun_;
};
......
......@@ -1547,7 +1547,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
if (impl()->IsEvalOrArguments(name)) {
if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) {
ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer);
return impl()->NullIdentifier();
return impl()->EmptyIdentifierString();
}
classifier()->RecordStrictModeFormalParameterError(
......@@ -1575,7 +1575,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
return impl()->GetSymbol();
} else {
ReportUnexpectedToken(next);
return impl()->NullIdentifier();
return impl()->EmptyIdentifierString();
}
}
......@@ -1594,7 +1594,7 @@ ParserBase<Impl>::ParseIdentifierOrStrictReservedWord(
*is_strict_reserved = true;
} else {
ReportUnexpectedToken(next);
return impl()->NullIdentifier();
return impl()->EmptyIdentifierString();
}
return impl()->GetSymbol();
......@@ -1606,7 +1606,7 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName() {
if (!Token::IsAnyIdentifier(next) && next != Token::ESCAPED_KEYWORD &&
!Token::IsKeyword(next)) {
ReportUnexpectedToken(next);
return impl()->NullIdentifier();
return impl()->EmptyIdentifierString();
}
return impl()->GetSymbol();
......@@ -1628,7 +1628,6 @@ ParserBase<Impl>::ParseIdentifierNameOrPrivateName() {
name = ParseIdentifierName();
key = factory()->NewStringLiteral(name, pos);
}
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(name);
return key;
}
......@@ -2131,7 +2130,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
if (*kind == ParsePropertyKind::kNotSet) {
ParsePropertyKindFromToken(peek(), kind);
}
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(*name);
return is_array_index ? factory()->NewNumberLiteral(index, pos)
: factory()->NewStringLiteral(*name, pos);
......@@ -2705,8 +2703,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN) {
}
scope->set_start_position(lhs_beg_pos);
// TODO(verwaest): Disable DCHECKs in failure mode?
RETURN_IF_PARSE_ERROR;
impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc);
expression =
......@@ -3828,7 +3824,7 @@ ParserBase<Impl>::ParseHoistableDeclaration(
impl()->GetDefaultStrings(&name, &variable_name);
name_validity = kSkipFunctionNameCheck;
} else {
bool is_strict_reserved;
bool is_strict_reserved = false;
bool is_await = false;
name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, &is_await);
name_validity = is_strict_reserved ? kFunctionNameIsStrictReserved
......@@ -3837,8 +3833,6 @@ ParserBase<Impl>::ParseHoistableDeclaration(
}
FuncNameInferrerState fni_state(&fni_);
// TODO(verwaest): Remove once we have FailureIdentifier.
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
impl()->PushEnclosingName(name);
FunctionKind kind = FunctionKindFor(flags);
......@@ -3862,7 +3856,6 @@ ParserBase<Impl>::ParseHoistableDeclaration(
!scope()->is_declaration_scope() &&
flags == ParseFunctionFlag::kIsNormal;
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareFunction(variable_name, function, mode, pos,
is_sloppy_block_function, names);
}
......@@ -3904,7 +3897,6 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
ExpressionT value = ParseClassLiteral(name, scanner()->location(),
is_strict_reserved, class_token_pos);
int end_pos = position();
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareClass(variable_name, value, names, class_token_pos,
end_pos);
}
......@@ -4138,7 +4130,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
DCHECK_EQ(Token::ARROW, peek());
DCHECK_IMPLIES(!has_error(), peek() == Token::ARROW);
if (scanner_->HasLineTerminatorBeforeNext()) {
// ASI inserts `;` after arrow parameters if a line terminator is found.
// `=> ...` is never a valid expression, so report as syntax error.
......
......@@ -2436,7 +2436,7 @@ void Parser::AddArrowFunctionFormalParameters(
void Parser::DeclareArrowFunctionFormalParameters(
ParserFormalParameters* parameters, Expression* expr,
const Scanner::Location& params_loc) {
if (expr->IsEmptyParentheses()) return;
if (expr->IsEmptyParentheses() || has_error()) return;
AddArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos);
......@@ -2446,7 +2446,8 @@ void Parser::DeclareArrowFunctionFormalParameters(
}
DeclareFormalParameters(parameters);
DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters());
DCHECK_IMPLIES(parameters->is_simple,
parameters->scope->has_simple_parameters());
}
void Parser::PrepareGeneratorVariables() {
......
......@@ -862,7 +862,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
V8_INLINE VariableProxy* ExpressionFromIdentifier(
const AstRawString* name, int start_position,
InferName infer = InferName::kYes) {
if (has_error()) return nullptr;
if (infer == InferName::kYes) {
fni_.PushVariableName(name);
}
......
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