| Index: src/preparser.cc
|
| diff --git a/src/preparser.cc b/src/preparser.cc
|
| index b1541f616afe133554881e99aec4f71a9f5e45e0..7e75e78ef9c2e0753c26e6f8bf9f5303ddc02f70 100644
|
| --- a/src/preparser.cc
|
| +++ b/src/preparser.cc
|
| @@ -102,8 +102,8 @@ PreParserExpression PreParserTraits::ParseFunctionLiteral(
|
|
|
|
|
| PreParser::PreParseResult PreParser::PreParseLazyFunction(
|
| - LanguageMode language_mode, FunctionKind kind, ParserRecorder* log,
|
| - Scanner::BookmarkScope* bookmark) {
|
| + LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters,
|
| + ParserRecorder* log, Scanner::BookmarkScope* bookmark) {
|
| log_ = log;
|
| // Lazy functions always have trivial outer scopes (no with/catch scopes).
|
| Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE);
|
| @@ -113,6 +113,7 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
|
| scope_->SetLanguageMode(language_mode);
|
| Scope* function_scope = NewScope(
|
| scope_, IsArrowFunction(kind) ? ARROW_SCOPE : FUNCTION_SCOPE, kind);
|
| + if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters();
|
| PreParserFactory function_factory(NULL);
|
| FunctionState function_state(&function_state_, &scope_, function_scope, kind,
|
| &function_factory);
|
| @@ -251,15 +252,33 @@ void PreParser::ParseStatementList(int end_token, bool* ok,
|
| }
|
|
|
| if (directive_prologue) {
|
| - if (statement.IsUseStrictLiteral()) {
|
| + bool use_strict_found = statement.IsUseStrictLiteral();
|
| + bool use_strong_found =
|
| + statement.IsUseStrongLiteral() && allow_strong_mode();
|
| +
|
| + if (use_strict_found) {
|
| scope_->SetLanguageMode(
|
| static_cast<LanguageMode>(scope_->language_mode() | STRICT));
|
| - } else if (statement.IsUseStrongLiteral() && allow_strong_mode()) {
|
| + } else if (use_strong_found) {
|
| scope_->SetLanguageMode(static_cast<LanguageMode>(
|
| scope_->language_mode() | STRONG));
|
| } else if (!statement.IsStringLiteral()) {
|
| directive_prologue = false;
|
| }
|
| +
|
| + if ((use_strict_found || use_strong_found) &&
|
| + !scope_->HasSimpleParameters()) {
|
| + // TC39 deemed "use strict" directives to be an error when occurring
|
| + // in the body of a function with non-simple parameter list, on
|
| + // 29/7/2015. https://goo.gl/ueA7Ln
|
| + //
|
| + // In V8, this also applies to "use strong " directives.
|
| + PreParserTraits::ReportMessageAt(
|
| + token_loc, MessageTemplate::kIllegalLanguageModeDirective,
|
| + use_strict_found ? "use strict" : "use strong");
|
| + *ok = false;
|
| + return;
|
| + }
|
| }
|
|
|
| // If we're allowed to reset to a bookmark, we will do so when we see a long
|
| @@ -1057,7 +1076,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
|
| Expect(Token::LPAREN, CHECK_OK);
|
| int start_position = scanner()->location().beg_pos;
|
| function_scope->set_start_position(start_position);
|
| - PreParserFormalParameters formals(nullptr);
|
| + PreParserFormalParameters formals(function_scope);
|
| ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK);
|
| Expect(Token::RPAREN, CHECK_OK);
|
| int formals_end_position = scanner()->location().end_pos;
|
|
|