Commit 180b6ec6 authored by mmaly@chromium.org's avatar mmaly@chromium.org

Disable const in strict mode.

Using const in strict mode yields SyntaxError.

Review URL: http://codereview.chromium.org/6592031/

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6974 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 417ee308
......@@ -226,6 +226,7 @@ function FormatMessage(message) {
strict_reserved_word: ["Use of future reserved word in strict mode"],
strict_delete: ["Delete of an unqualified identifier in strict mode."],
strict_delete_property: ["Cannot delete property '", "%0", "' of ", "%1"],
strict_const: ["Use of const in strict mode."],
};
}
var message_type = %MessageGetType(message);
......
......@@ -1515,6 +1515,11 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
Consume(Token::VAR);
} else if (peek() == Token::CONST) {
Consume(Token::CONST);
if (temp_scope_->StrictMode()) {
ReportMessage("strict_const", Vector<const char*>::empty());
*ok = false;
return NULL;
}
mode = Variable::CONST;
is_const = true;
} else {
......
......@@ -280,6 +280,11 @@ CheckStrictMode("function strict() { print(--arguments); }", SyntaxError);
CheckStrictMode("function strict() { var x = --eval; }", SyntaxError);
CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError);
// Use of const in strict mode is disallowed in anticipation of ES Harmony.
CheckStrictMode("const x = 0;", SyntaxError);
CheckStrictMode("for (const x = 0; false;) {}", SyntaxError);
CheckStrictMode("function strict() { const x = 0; }", SyntaxError);
// Delete of an unqualified identifier
CheckStrictMode("delete unqualified;", SyntaxError);
CheckStrictMode("function strict() { delete unqualified; }", SyntaxError);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment