Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: test/preparser/strict-identifiers.pyt

Issue 7987002: Disallow strict mode FutureReservedWords as break/continue labels in strict mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/preparser/strict-identifiers.pyt
diff --git a/test/preparser/strict-identifiers.pyt b/test/preparser/strict-identifiers.pyt
index 72808e25bfa993c2dc8798332931a0c70e0c672c..d0ca94490258eee1202ff00a61b184a6704b37d7 100644
--- a/test/preparser/strict-identifiers.pyt
+++ b/test/preparser/strict-identifiers.pyt
@@ -138,6 +138,30 @@ setter_arg = StrictTemplate("setter-param-$id", """
var x = {set foo($id) { }};
""")
+label_normal = Template("label-normal-$id", """
+ $id: '';
+""")
+
+label_strict = StrictTemplate("label-strict-$id", """
+ $id: '';
+""")
+
+break_normal = Template("break-normal-$id", """
+ break $id;
+""")
+
+break_strict = StrictTemplate("break-strict-$id", """
+ break $id;
+""")
+
+continue_normal = Template("continue-normal-$id", """
+ continue $id;
+""")
+
+continue_strict = StrictTemplate("continue-strict-$id", """
+ continue $id;
Lasse Reichstein 2011/09/22 12:50:19 IIRC, you can't have break and continue outside of
Steven 2011/09/22 16:48:32 Done.
+""")
+
non_strict_use = Template("nonstrict-$id", """
var $id = 42;
$id++;
@@ -162,6 +186,7 @@ non_strict_use = Template("nonstrict-$id", """
function $id($id) { }
x = {$id: 42};
x = {get $id() {}, set $id(value) {}};
+ $id: '';
""")
identifier_name_source = """
@@ -197,6 +222,12 @@ for id in ["eval", "arguments"]:
prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix")
postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix")
postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix")
+ label_normal({"id": id}, None)
+ label_strict({"id": id}, None)
+ break_normal({"id": id}, None)
+ break_strict({"id": id}, None)
+ continue_normal({"id": id}, None)
+ continue_strict({"id": id}, None)
non_strict_use({"id": id}, None)
@@ -205,10 +236,32 @@ for id in ["eval", "arguments"]:
for reserved_word in reserved_words + strict_reserved_words:
if (reserved_word in strict_reserved_words):
message = "strict_reserved_word"
Lasse Reichstein 2011/09/22 12:50:19 Make a label_message = message here and in case th
Steven 2011/09/22 16:48:32 Done.
+ label_normal({"id": reserved_word}, None)
+ break_normal({"id": reserved_word}, None)
+ continue_normal({"id": reserved_word}, None)
+ label_strict({"id": reserved_word}, message)
+ break_strict({"id": reserved_word}, message)
+ continue_strict({"id": reserved_word}, message)
elif (reserved_word == "const"):
message = "unexpected_token"
+ label_normal({"id": reserved_word}, message)
+ break_normal({"id": reserved_word}, message)
+ continue_normal({"id": reserved_word}, message)
+ # The error message for this case is different because
+ # ParseLabelledStatementOrExpression will try to parse this as an expression
+ # first, effectively disallowing the use in ParseVariableDeclarations, i.e.
+ # the preparser never sees that 'const' was intended to be a label.
+ label_strict({"id": reserved_word}, "strict_const")
+ break_strict({"id": reserved_word}, message)
+ continue_strict({"id": reserved_word}, message)
else:
message = "reserved_word"
+ label_normal({"id": reserved_word}, message)
+ break_normal({"id": reserved_word}, message)
+ continue_normal({"id": reserved_word}, message)
+ label_strict({"id": reserved_word}, message)
+ break_strict({"id": reserved_word}, message)
+ continue_strict({"id": reserved_word}, message)
arg_name_own({"id":reserved_word}, message)
arg_name_nested({"id":reserved_word}, message)
setter_arg({"id": reserved_word}, message)
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698