Reviewers: marja,
Description:
[strong] Deprecate ellisions
[email protected]
BUG=
Please review this at https://codereview.chromium.org/950303002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -0 lines):
M src/messages.js
M src/preparser.h
A test/mjsunit/strong/arrays.js
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index
7d98cea1922bf39505b3b556525da944ba4c419b..9ec122370eff0cf5eb5619cca3865a9d6f91b909
100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -161,6 +161,7 @@ var kMessages = {
strict_cannot_assign: ["Cannot assign to read only '", "%0", "'
in strict mode"],
strict_poison_pill: ["'caller', 'callee', and 'arguments'
properties may not be accessed on strict mode functions or the arguments
objects for calls to them"],
strict_caller: ["Illegal access to a strict mode caller
function."],
+ strong_ellision: ["Please don't use arrays with holes in
strong mode, use maps instead"],
strong_arguments: ["Please don't use 'arguments' in strong
mode, use '...args' instead"],
strong_equal: ["Please don't use '==' or '!=' in strong
mode, use '===' or '!==' instead"],
strong_delete: ["Please don't use 'delete' in strong
mode, use maps or sets instead"],
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index
8171f9433a4627c9b8fe5f1c5ac6a72d73a9ae4a..41b3a31f0e1169068eaf2968fe55b67fc3904ee4
100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -2013,6 +2013,11 @@ typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::ParseArrayLiteral(
while (peek() != Token::RBRACK) {
ExpressionT elem = this->EmptyExpression();
if (peek() == Token::COMMA) {
+ if (is_strong(language_mode())) {
+ ReportMessageAt(scanner()->peek_location(), "strong_ellision");
+ *ok = false;
+ return this->EmptyExpression();
+ }
elem = this->GetLiteralTheHole(peek_position(), factory());
} else {
elem = this->ParseAssignmentExpression(true, CHECK_OK);
Index: test/mjsunit/strong/arrays.js
diff --git a/test/mjsunit/strong/arrays.js b/test/mjsunit/strong/arrays.js
new file mode 100644
index
0000000000000000000000000000000000000000..b9e4fad357d9f6b4091db45ed6001c10f012838b
--- /dev/null
+++ b/test/mjsunit/strong/arrays.js
@@ -0,0 +1,12 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --strong-mode
+
+(function NoEllisions() {
+ assertThrows("'use strong'; [,]", SyntaxError);
+ assertThrows("'use strong'; [,3]", SyntaxError);
+ assertThrows("'use strong'; [3,,4]", SyntaxError);
+ assertTrue(eval("'use strong'; [3,] !== [3,4,]"));
+})();
--
--
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/d/optout.