Commit d4c46181 authored by adamk's avatar adamk Committed by Commit bot

Remove --harmony-for-in flag which is always false

The ES spec has been updated to include this legacy syntax in Annex B:
https://tc39.github.io/ecma262/#sec-initializers-in-forin-statement-heads

R=neis@chromium.org
BUG=v8:4942

Review-Url: https://codereview.chromium.org/2407863003
Cr-Commit-Position: refs/heads/master@{#40189}
parent b6954db9
...@@ -3055,7 +3055,6 @@ void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate, ...@@ -3055,7 +3055,6 @@ void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
void Genesis::InitializeGlobal_##id() {} void Genesis::InitializeGlobal_##id() {}
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_for_in)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
...@@ -3648,7 +3647,6 @@ bool Genesis::InstallExperimentalNatives() { ...@@ -3648,7 +3647,6 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_simd_natives[] = {"native harmony-simd.js", static const char* harmony_simd_natives[] = {"native harmony-simd.js",
nullptr}; nullptr};
static const char* harmony_do_expressions_natives[] = {nullptr}; static const char* harmony_do_expressions_natives[] = {nullptr};
static const char* harmony_for_in_natives[] = {nullptr};
static const char* harmony_regexp_lookbehind_natives[] = {nullptr}; static const char* harmony_regexp_lookbehind_natives[] = {nullptr};
static const char* harmony_restrictive_declarations_natives[] = {nullptr}; static const char* harmony_restrictive_declarations_natives[] = {nullptr};
static const char* harmony_regexp_named_captures_natives[] = {nullptr}; static const char* harmony_regexp_named_captures_natives[] = {nullptr};
......
...@@ -203,7 +203,6 @@ DEFINE_IMPLICATION(es_staging, move_object_start) ...@@ -203,7 +203,6 @@ DEFINE_IMPLICATION(es_staging, move_object_start)
"harmony restrictions on generator declarations") \ "harmony restrictions on generator declarations") \
V(harmony_regexp_named_captures, "harmony regexp named captures") \ V(harmony_regexp_named_captures, "harmony regexp named captures") \
V(harmony_regexp_property, "harmony unicode regexp property classes") \ V(harmony_regexp_property, "harmony unicode regexp property classes") \
V(harmony_for_in, "harmony for-in syntax") \
V(harmony_trailing_commas, \ V(harmony_trailing_commas, \
"harmony trailing commas in function parameter lists") \ "harmony trailing commas in function parameter lists") \
V(harmony_class_fields, "harmony public fields in class literals") V(harmony_class_fields, "harmony public fields in class literals")
......
...@@ -196,7 +196,6 @@ class ParserBase { ...@@ -196,7 +196,6 @@ class ParserBase {
allow_tailcalls_(false), allow_tailcalls_(false),
allow_harmony_restrictive_declarations_(false), allow_harmony_restrictive_declarations_(false),
allow_harmony_do_expressions_(false), allow_harmony_do_expressions_(false),
allow_harmony_for_in_(false),
allow_harmony_function_sent_(false), allow_harmony_function_sent_(false),
allow_harmony_async_await_(false), allow_harmony_async_await_(false),
allow_harmony_restrictive_generators_(false), allow_harmony_restrictive_generators_(false),
...@@ -212,7 +211,6 @@ class ParserBase { ...@@ -212,7 +211,6 @@ class ParserBase {
ALLOW_ACCESSORS(tailcalls); ALLOW_ACCESSORS(tailcalls);
ALLOW_ACCESSORS(harmony_restrictive_declarations); ALLOW_ACCESSORS(harmony_restrictive_declarations);
ALLOW_ACCESSORS(harmony_do_expressions); ALLOW_ACCESSORS(harmony_do_expressions);
ALLOW_ACCESSORS(harmony_for_in);
ALLOW_ACCESSORS(harmony_function_sent); ALLOW_ACCESSORS(harmony_function_sent);
ALLOW_ACCESSORS(harmony_async_await); ALLOW_ACCESSORS(harmony_async_await);
ALLOW_ACCESSORS(harmony_restrictive_generators); ALLOW_ACCESSORS(harmony_restrictive_generators);
...@@ -1450,7 +1448,6 @@ class ParserBase { ...@@ -1450,7 +1448,6 @@ class ParserBase {
bool allow_tailcalls_; bool allow_tailcalls_;
bool allow_harmony_restrictive_declarations_; bool allow_harmony_restrictive_declarations_;
bool allow_harmony_do_expressions_; bool allow_harmony_do_expressions_;
bool allow_harmony_for_in_;
bool allow_harmony_function_sent_; bool allow_harmony_function_sent_;
bool allow_harmony_async_await_; bool allow_harmony_async_await_;
bool allow_harmony_restrictive_generators_; bool allow_harmony_restrictive_generators_;
...@@ -5181,13 +5178,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement( ...@@ -5181,13 +5178,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
for_info.mode == ForEachStatement::ITERATE || for_info.mode == ForEachStatement::ITERATE ||
bound_names_are_lexical || bound_names_are_lexical ||
!impl()->IsIdentifier( !impl()->IsIdentifier(
for_info.parsing_result.declarations[0].pattern) || for_info.parsing_result.declarations[0].pattern))) {
allow_harmony_for_in())) {
// Only increment the use count if we would have let this through
// without the flag.
if (allow_harmony_for_in()) {
impl()->CountUsage(v8::Isolate::kForInInitializer);
}
impl()->ReportMessageAt( impl()->ReportMessageAt(
for_info.parsing_result.first_initializer_loc, for_info.parsing_result.first_initializer_loc,
MessageTemplate::kForInOfLoopInitializer, MessageTemplate::kForInOfLoopInitializer,
......
...@@ -674,7 +674,6 @@ Parser::Parser(ParseInfo* info) ...@@ -674,7 +674,6 @@ Parser::Parser(ParseInfo* info)
set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() &&
info->isolate()->is_tail_call_elimination_enabled()); info->isolate()->is_tail_call_elimination_enabled());
set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
set_allow_harmony_for_in(FLAG_harmony_for_in);
set_allow_harmony_function_sent(FLAG_harmony_function_sent); set_allow_harmony_function_sent(FLAG_harmony_function_sent);
set_allow_harmony_restrictive_declarations( set_allow_harmony_restrictive_declarations(
FLAG_harmony_restrictive_declarations); FLAG_harmony_restrictive_declarations);
...@@ -1969,7 +1968,6 @@ Block* Parser::RewriteForVarInLegacy(const ForInfo& for_info) { ...@@ -1969,7 +1968,6 @@ Block* Parser::RewriteForVarInLegacy(const ForInfo& for_info) {
for_info.parsing_result.declarations[0]; for_info.parsing_result.declarations[0];
if (!IsLexicalVariableMode(for_info.parsing_result.descriptor.mode) && if (!IsLexicalVariableMode(for_info.parsing_result.descriptor.mode) &&
decl.pattern->IsVariableProxy() && decl.initializer != nullptr) { decl.pattern->IsVariableProxy() && decl.initializer != nullptr) {
DCHECK(!allow_harmony_for_in());
++use_counts_[v8::Isolate::kForInInitializer]; ++use_counts_[v8::Isolate::kForInInitializer];
const AstRawString* name = decl.pattern->AsVariableProxy()->raw_name(); const AstRawString* name = decl.pattern->AsVariableProxy()->raw_name();
VariableProxy* single_var = NewUnresolved(name); VariableProxy* single_var = NewUnresolved(name);
...@@ -3325,7 +3323,6 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( ...@@ -3325,7 +3323,6 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
#define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
SET_ALLOW(natives); SET_ALLOW(natives);
SET_ALLOW(harmony_do_expressions); SET_ALLOW(harmony_do_expressions);
SET_ALLOW(harmony_for_in);
SET_ALLOW(harmony_function_sent); SET_ALLOW(harmony_function_sent);
SET_ALLOW(harmony_restrictive_declarations); SET_ALLOW(harmony_restrictive_declarations);
SET_ALLOW(harmony_async_await); SET_ALLOW(harmony_async_await);
......
...@@ -1297,7 +1297,6 @@ enum ParserFlag { ...@@ -1297,7 +1297,6 @@ enum ParserFlag {
kAllowNatives, kAllowNatives,
kAllowHarmonyFunctionSent, kAllowHarmonyFunctionSent,
kAllowHarmonyRestrictiveDeclarations, kAllowHarmonyRestrictiveDeclarations,
kAllowHarmonyForIn,
kAllowHarmonyAsyncAwait, kAllowHarmonyAsyncAwait,
kAllowHarmonyRestrictiveGenerators, kAllowHarmonyRestrictiveGenerators,
kAllowHarmonyTrailingCommas, kAllowHarmonyTrailingCommas,
...@@ -1319,7 +1318,6 @@ void SetParserFlags(i::ParserBase<Traits>* parser, ...@@ -1319,7 +1318,6 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
flags.Contains(kAllowHarmonyFunctionSent)); flags.Contains(kAllowHarmonyFunctionSent));
parser->set_allow_harmony_restrictive_declarations( parser->set_allow_harmony_restrictive_declarations(
flags.Contains(kAllowHarmonyRestrictiveDeclarations)); flags.Contains(kAllowHarmonyRestrictiveDeclarations));
parser->set_allow_harmony_for_in(flags.Contains(kAllowHarmonyForIn));
parser->set_allow_harmony_async_await( parser->set_allow_harmony_async_await(
flags.Contains(kAllowHarmonyAsyncAwait)); flags.Contains(kAllowHarmonyAsyncAwait));
parser->set_allow_harmony_restrictive_generators( parser->set_allow_harmony_restrictive_generators(
...@@ -8115,22 +8113,29 @@ TEST(AsyncAwaitModuleErrors) { ...@@ -8115,22 +8113,29 @@ TEST(AsyncAwaitModuleErrors) {
TEST(RestrictiveForInErrors) { TEST(RestrictiveForInErrors) {
// clang-format off // clang-format off
const char* context_data[][2] = { const char* strict_context_data[][2] = {
{ "'use strict'", "" }, { "'use strict'", "" },
{ NULL, NULL }
};
const char* sloppy_context_data[][2] = {
{ "", "" }, { "", "" },
{ NULL, NULL } { NULL, NULL }
}; };
const char* error_data[] = { const char* error_data[] = {
"for (var x = 0 in {});",
"for (const x = 0 in {});", "for (const x = 0 in {});",
"for (let x = 0 in {});", "for (let x = 0 in {});",
NULL NULL
}; };
const char* sloppy_data[] = {
"for (var x = 0 in {});",
NULL
};
// clang-format on // clang-format on
static const ParserFlag always_flags[] = {kAllowHarmonyForIn}; RunParserSyncTest(strict_context_data, error_data, kError);
RunParserSyncTest(context_data, error_data, kError, nullptr, 0, always_flags, RunParserSyncTest(strict_context_data, sloppy_data, kError);
arraysize(always_flags)); RunParserSyncTest(sloppy_context_data, error_data, kError);
RunParserSyncTest(sloppy_context_data, sloppy_data, kSuccess);
} }
TEST(NoDuplicateGeneratorsInBlock) { TEST(NoDuplicateGeneratorsInBlock) {
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --noharmony-for-in
function props(x) { function props(x) {
var array = []; var array = [];
for (var p in x) array.push(p); for (var p in x) array.push(p);
...@@ -141,6 +139,13 @@ function props(x) { ...@@ -141,6 +139,13 @@ function props(x) {
(function forInInitialize() { (function forInInitialize() {
for (var hest = 'hest' in {}) { } for (var hest = 'hest' in {}) { }
assertEquals('hest', hest, "empty-no-override"); assertEquals('hest', hest, "empty-no-override");
// Lexical variables are disallowed
assertThrows("for (const x = 0 in {});", SyntaxError);
assertThrows("for (let x = 0 in {});", SyntaxError);
// In strict mode, var is disallowed
assertThrows("'use strict'; for (var x = 0 in {});", SyntaxError);
})(); })();
(function forInObjects() { (function forInObjects() {
......
// 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: --harmony-for-in
assertThrows("for (var x = 0 in {});", SyntaxError);
assertThrows("for (const x = 0 in {});", SyntaxError);
assertThrows("for (let x = 0 in {});", 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