Fix bug with multiple directives in the preparser
The preparser should ignore "use strong" if the --strong_mode flag is not turned on, but this should not stop processing subsequent directives. R=rossberg@chromium.org BUG= LOG=N Review URL: https://codereview.chromium.org/1752753002 Cr-Commit-Position: refs/heads/master@{#34392}
This commit is contained in:
parent
0cb8a1b774
commit
86a9ef31c7
@ -376,7 +376,8 @@ class PreParserStatement {
|
||||
}
|
||||
|
||||
bool IsStringLiteral() {
|
||||
return code_ == kStringLiteralExpressionStatement;
|
||||
return code_ == kStringLiteralExpressionStatement
|
||||
|| IsUseStrictLiteral() || IsUseStrongLiteral();
|
||||
}
|
||||
|
||||
bool IsUseStrictLiteral() {
|
||||
|
@ -6029,6 +6029,31 @@ TEST(LanguageModeDirectives) {
|
||||
}
|
||||
|
||||
|
||||
TEST(MultipleLanguageModeDirectives) {
|
||||
const char* context_data[][2] = {
|
||||
{ "'use strict'; 'use strong';", "" },
|
||||
{ "'use strong'; 'use strict';", "" },
|
||||
{ "function f() { 'use strict'; 'use strong';", "}" },
|
||||
{ "function f() { 'use strong'; 'use strict';", "}" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
const char* strict_error_data[] = {
|
||||
"var x = 42; delete x",
|
||||
NULL};
|
||||
|
||||
const char* strong_error_data[] = {
|
||||
"var x = 42",
|
||||
NULL};
|
||||
|
||||
static const ParserFlag strong_mode_flags[] = {kAllowStrongMode};
|
||||
RunParserSyncTest(context_data, strict_error_data, kError,
|
||||
strong_mode_flags, arraysize(strong_mode_flags));
|
||||
RunParserSyncTest(context_data, strong_error_data, kError, NULL, 0,
|
||||
strong_mode_flags, arraysize(strong_mode_flags));
|
||||
}
|
||||
|
||||
|
||||
TEST(PropertyNameEvalArguments) {
|
||||
const char* context_data[][2] = {{"'use strict';", ""},
|
||||
{"'use strong';", ""},
|
||||
|
Loading…
Reference in New Issue
Block a user