Reviewers: Michael Starzinger,
Description:
Fix parsing of 'use strict' directive to match spec
[email protected]
BUG=
Please review this at https://codereview.chromium.org/23474007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/parser.cc
M src/preparser.cc
M test/mjsunit/strict-mode.js
M test/preparser/preparser.expectation
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
e4a6bb2d3a643ba4455a96c881299016db95cd67..5b630e8b5377e8e7a55f81b0b56d3c1e7b45aba0
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -914,13 +914,9 @@ void*
Parser::ParseSourceElements(ZoneList<Statement*>* processor,
// TODO(ES6): Fix entering extended mode, once it is specified.
top_scope_->SetLanguageMode(allow_harmony_scoping()
? EXTENDED_MODE : STRICT_MODE);
- // "use strict" is the only directive for now.
- directive_prologue = false;
}
- } else {
- // End of the directive prologue.
- directive_prologue = false;
}
+ directive_prologue = false;
}
processor->Add(stat, zone());
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index
36a94a3315b312d89922fde236426fc5570580bf..935c3c57ed7b9df5763fec42e678462fefe4ce51
100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -185,9 +185,8 @@ PreParser::SourceElements
PreParser::ParseSourceElements(int end_token,
if (statement.IsUseStrictLiteral()) {
set_language_mode(allow_harmony_scoping() ?
i::EXTENDED_MODE : i::STRICT_MODE);
- } else if (!statement.IsStringLiteral()) {
- allow_directive_prologue = false;
}
+ allow_directive_prologue = false;
}
}
return kUnknownSourceElements;
Index: test/mjsunit/strict-mode.js
diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js
index
5fb404a7990913cc953fe400315a3e4e455ced4a..1bb626ce0d31691c37a32e7edd700e35e5db4ba5
100644
--- a/test/mjsunit/strict-mode.js
+++ b/test/mjsunit/strict-mode.js
@@ -77,14 +77,11 @@ assertThrows("function foo (x) 'use strict'; {}",
SyntaxError);
with ({}) {};
})();
-// Multiple directives, including "use strict".
-assertThrows('\
-"directive 1";\
-"another directive";\
-"use strict";\
-"directive after strict";\
-"and one more";\
-with({}) {}', SyntaxError);
+(function UseStrictNonDirective2() {
+ "use sanity";
+ "use strict";
+ with ({}) {};
+})();
// 'with' disallowed in strict mode.
CheckStrictMode("with({}) {}", SyntaxError);
@@ -160,11 +157,11 @@ CheckStrictMode("function octal() { return '\\032';
}");
})();
// Octal before "use strict"
-assertThrows('\
+eval('\
function strict() {\
"octal\\032directive";\
"use strict";\
- }', SyntaxError);
+ }');
// Duplicate data properties.
CheckStrictMode("var x = { dupe : 1, nondupe: 3, dupe : 2 };",
SyntaxError);
Index: test/preparser/preparser.expectation
diff --git a/test/preparser/preparser.expectation
b/test/preparser/preparser.expectation
index
638f90e0b8d1ebe457228b0850438641b05a8649..f768f04008131ddcb45031bf606eb6733341301b
100644
--- a/test/preparser/preparser.expectation
+++ b/test/preparser/preparser.expectation
@@ -7,7 +7,6 @@ strict-octal-number:strict_octal_literal
strict-octal-string:strict_octal_literal
strict-octal-regexp:strict_octal_literal
strict-octal-use-strict-after:strict_octal_literal
-strict-octal-use-strict-before:strict_octal_literal
strict-const:strict_const
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.