Reviewers: ulan,
Description:
Fix pre-parsing of 'use strict' directive after string literals.
[email protected]
TEST=mjsunit/regress/regress-parse-use-strict
Please review this at https://codereview.chromium.org/27025002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+14, -12 lines):
M src/preparser.h
A + test/mjsunit/regress/regress-parse-use-strict.js
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index
44bd85c85e2d01070068afa4bb39fe4b972477dd..08766e9160fee303d0805180c2878827db5e54a9
100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -444,7 +444,7 @@ class PreParser {
}
bool IsStringLiteral() {
- return code_ != kUnknownStatement;
+ return code_ == kStringLiteralExpressionStatement;
}
bool IsUseStrictLiteral() {
Index: test/mjsunit/regress/regress-parse-use-strict.js
diff --git a/test/mjsunit/regress/regress-crbug-248025.js
b/test/mjsunit/regress/regress-parse-use-strict.js
similarity index 71%
copy from test/mjsunit/regress/regress-crbug-248025.js
copy to test/mjsunit/regress/regress-parse-use-strict.js
index
c5988595663c9622853e98585ed4a4e9bed089b1..9dd0f4c97c026d74f2c2cc0213eb22d0e2a8a87e
100644
--- a/test/mjsunit/regress/regress-crbug-248025.js
+++ b/test/mjsunit/regress/regress-parse-use-strict.js
@@ -25,16 +25,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-iteration
-
// Filler long enough to trigger lazy parsing.
-var filler = "//" + new Array(1024).join('x');
+var filler = "/*" + new Array(1024).join('x') + "*/";
+
+// Snippet trying to switch to strict mode.
+var strict = '"use strict"; with({}) {}';
+
+// Test switching to strict mode after string literal.
+assertThrows('function f() { "use sanity";' + strict + '}');
+assertThrows('function f() { "use sanity";' + strict + filler + '}');
-// Test that the pre-parser does not crash when the expected contextual
-// keyword as part if a 'for' statement is not and identifier.
-try {
- eval(filler + "\nfunction f() { for (x : y) { } }");
- throw "not reached";
-} catch (e) {
- if (!(e instanceof SyntaxError)) throw e;
-}
+// Test switching to strict mode after function declaration.
+// We must use eval instead of assertDoesNotThrow here to make sure that
+// lazy parsing is triggered. Otherwise the bug won't reproduce.
+eval('function f() { function g() {}' + strict + '}');
+eval('function f() { function g() {}' + strict + filler + '}');
--
--
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.