Commit b7922406 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Move recording of strict eval arguments to clients

Change-Id: Icbda182a894ce6508efbfa3bdb17ba3adce360c7
Reviewed-on: https://chromium-review.googlesource.com/c/1349573Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57794}
parent 8c359f64
...@@ -1441,8 +1441,10 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifier( ...@@ -1441,8 +1441,10 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifier(
ExpressionClassifier classifier(this); ExpressionClassifier classifier(this);
auto result = ParseAndClassifyIdentifier(); auto result = ParseAndClassifyIdentifier();
if (allow_restricted_identifiers == kDontAllowRestrictedIdentifiers) { if (allow_restricted_identifiers == kDontAllowRestrictedIdentifiers &&
ValidatePattern(); is_strict(language_mode()) && impl()->IsEvalOrArguments(result)) {
impl()->ReportMessageAt(scanner()->location(),
MessageTemplate::kStrictEvalArguments);
} }
return result; return result;
...@@ -1462,7 +1464,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() { ...@@ -1462,7 +1464,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
// is actually a formal parameter. Therefore besides the errors that we // is actually a formal parameter. Therefore besides the errors that we
// must detect because we know we're in strict mode, we also record any // must detect because we know we're in strict mode, we also record any
// error that we might make in the future once we know the language mode. // error that we might make in the future once we know the language mode.
if (impl()->IsEvalOrArguments(name)) { if (V8_UNLIKELY(impl()->IsEvalOrArguments(name))) {
if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) { if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) {
ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer); ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer);
return impl()->EmptyIdentifierString(); return impl()->EmptyIdentifierString();
...@@ -1470,10 +1472,6 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() { ...@@ -1470,10 +1472,6 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
classifier()->RecordStrictModeFormalParameterError( classifier()->RecordStrictModeFormalParameterError(
scanner()->location(), MessageTemplate::kStrictEvalArguments); scanner()->location(), MessageTemplate::kStrictEvalArguments);
if (is_strict(language_mode())) {
classifier()->RecordPatternError(scanner()->location(),
MessageTemplate::kStrictEvalArguments);
}
} }
return name; return name;
...@@ -1585,8 +1583,15 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBindingPattern() { ...@@ -1585,8 +1583,15 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBindingPattern() {
if (Token::IsAnyIdentifier(token)) { if (Token::IsAnyIdentifier(token)) {
IdentifierT name = ParseAndClassifyIdentifier(); IdentifierT name = ParseAndClassifyIdentifier();
result = impl()->ExpressionFromIdentifier(name, beg_pos); if (V8_UNLIKELY(is_strict(language_mode()) &&
} else { impl()->IsEvalOrArguments(name))) {
impl()->ReportMessageAt(scanner()->location(),
MessageTemplate::kStrictEvalArguments);
return impl()->FailureExpression();
}
return impl()->ExpressionFromIdentifier(name, beg_pos);
}
CheckStackOverflow(); CheckStackOverflow();
classifier()->RecordNonSimpleParameter(); classifier()->RecordNonSimpleParameter();
...@@ -1598,7 +1603,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBindingPattern() { ...@@ -1598,7 +1603,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBindingPattern() {
ReportUnexpectedToken(Next()); ReportUnexpectedToken(Next());
return impl()->FailureExpression(); return impl()->FailureExpression();
} }
}
ValidateBindingPattern(); ValidateBindingPattern();
return result; return 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