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}
This commit is contained in:
parent
b6954db942
commit
d4c4618174
@ -3055,7 +3055,6 @@ void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
|
||||
void Genesis::InitializeGlobal_##id() {}
|
||||
|
||||
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_named_captures)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
|
||||
@ -3648,7 +3647,6 @@ bool Genesis::InstallExperimentalNatives() {
|
||||
static const char* harmony_simd_natives[] = {"native harmony-simd.js",
|
||||
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_restrictive_declarations_natives[] = {nullptr};
|
||||
static const char* harmony_regexp_named_captures_natives[] = {nullptr};
|
||||
|
@ -203,7 +203,6 @@ DEFINE_IMPLICATION(es_staging, move_object_start)
|
||||
"harmony restrictions on generator declarations") \
|
||||
V(harmony_regexp_named_captures, "harmony regexp named captures") \
|
||||
V(harmony_regexp_property, "harmony unicode regexp property classes") \
|
||||
V(harmony_for_in, "harmony for-in syntax") \
|
||||
V(harmony_trailing_commas, \
|
||||
"harmony trailing commas in function parameter lists") \
|
||||
V(harmony_class_fields, "harmony public fields in class literals")
|
||||
|
@ -196,7 +196,6 @@ class ParserBase {
|
||||
allow_tailcalls_(false),
|
||||
allow_harmony_restrictive_declarations_(false),
|
||||
allow_harmony_do_expressions_(false),
|
||||
allow_harmony_for_in_(false),
|
||||
allow_harmony_function_sent_(false),
|
||||
allow_harmony_async_await_(false),
|
||||
allow_harmony_restrictive_generators_(false),
|
||||
@ -212,7 +211,6 @@ class ParserBase {
|
||||
ALLOW_ACCESSORS(tailcalls);
|
||||
ALLOW_ACCESSORS(harmony_restrictive_declarations);
|
||||
ALLOW_ACCESSORS(harmony_do_expressions);
|
||||
ALLOW_ACCESSORS(harmony_for_in);
|
||||
ALLOW_ACCESSORS(harmony_function_sent);
|
||||
ALLOW_ACCESSORS(harmony_async_await);
|
||||
ALLOW_ACCESSORS(harmony_restrictive_generators);
|
||||
@ -1450,7 +1448,6 @@ class ParserBase {
|
||||
bool allow_tailcalls_;
|
||||
bool allow_harmony_restrictive_declarations_;
|
||||
bool allow_harmony_do_expressions_;
|
||||
bool allow_harmony_for_in_;
|
||||
bool allow_harmony_function_sent_;
|
||||
bool allow_harmony_async_await_;
|
||||
bool allow_harmony_restrictive_generators_;
|
||||
@ -5181,13 +5178,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
|
||||
for_info.mode == ForEachStatement::ITERATE ||
|
||||
bound_names_are_lexical ||
|
||||
!impl()->IsIdentifier(
|
||||
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);
|
||||
}
|
||||
for_info.parsing_result.declarations[0].pattern))) {
|
||||
impl()->ReportMessageAt(
|
||||
for_info.parsing_result.first_initializer_loc,
|
||||
MessageTemplate::kForInOfLoopInitializer,
|
||||
|
@ -674,7 +674,6 @@ Parser::Parser(ParseInfo* info)
|
||||
set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() &&
|
||||
info->isolate()->is_tail_call_elimination_enabled());
|
||||
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_restrictive_declarations(
|
||||
FLAG_harmony_restrictive_declarations);
|
||||
@ -1969,7 +1968,6 @@ Block* Parser::RewriteForVarInLegacy(const ForInfo& for_info) {
|
||||
for_info.parsing_result.declarations[0];
|
||||
if (!IsLexicalVariableMode(for_info.parsing_result.descriptor.mode) &&
|
||||
decl.pattern->IsVariableProxy() && decl.initializer != nullptr) {
|
||||
DCHECK(!allow_harmony_for_in());
|
||||
++use_counts_[v8::Isolate::kForInInitializer];
|
||||
const AstRawString* name = decl.pattern->AsVariableProxy()->raw_name();
|
||||
VariableProxy* single_var = NewUnresolved(name);
|
||||
@ -3325,7 +3323,6 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
|
||||
#define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
|
||||
SET_ALLOW(natives);
|
||||
SET_ALLOW(harmony_do_expressions);
|
||||
SET_ALLOW(harmony_for_in);
|
||||
SET_ALLOW(harmony_function_sent);
|
||||
SET_ALLOW(harmony_restrictive_declarations);
|
||||
SET_ALLOW(harmony_async_await);
|
||||
|
@ -1297,7 +1297,6 @@ enum ParserFlag {
|
||||
kAllowNatives,
|
||||
kAllowHarmonyFunctionSent,
|
||||
kAllowHarmonyRestrictiveDeclarations,
|
||||
kAllowHarmonyForIn,
|
||||
kAllowHarmonyAsyncAwait,
|
||||
kAllowHarmonyRestrictiveGenerators,
|
||||
kAllowHarmonyTrailingCommas,
|
||||
@ -1319,7 +1318,6 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
|
||||
flags.Contains(kAllowHarmonyFunctionSent));
|
||||
parser->set_allow_harmony_restrictive_declarations(
|
||||
flags.Contains(kAllowHarmonyRestrictiveDeclarations));
|
||||
parser->set_allow_harmony_for_in(flags.Contains(kAllowHarmonyForIn));
|
||||
parser->set_allow_harmony_async_await(
|
||||
flags.Contains(kAllowHarmonyAsyncAwait));
|
||||
parser->set_allow_harmony_restrictive_generators(
|
||||
@ -8115,22 +8113,29 @@ TEST(AsyncAwaitModuleErrors) {
|
||||
|
||||
TEST(RestrictiveForInErrors) {
|
||||
// clang-format off
|
||||
const char* context_data[][2] = {
|
||||
const char* strict_context_data[][2] = {
|
||||
{ "'use strict'", "" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
const char* sloppy_context_data[][2] = {
|
||||
{ "", "" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
const char* error_data[] = {
|
||||
"for (var x = 0 in {});",
|
||||
"for (const x = 0 in {});",
|
||||
"for (let x = 0 in {});",
|
||||
NULL
|
||||
};
|
||||
const char* sloppy_data[] = {
|
||||
"for (var x = 0 in {});",
|
||||
NULL
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static const ParserFlag always_flags[] = {kAllowHarmonyForIn};
|
||||
RunParserSyncTest(context_data, error_data, kError, nullptr, 0, always_flags,
|
||||
arraysize(always_flags));
|
||||
RunParserSyncTest(strict_context_data, error_data, kError);
|
||||
RunParserSyncTest(strict_context_data, sloppy_data, kError);
|
||||
RunParserSyncTest(sloppy_context_data, error_data, kError);
|
||||
RunParserSyncTest(sloppy_context_data, sloppy_data, kSuccess);
|
||||
}
|
||||
|
||||
TEST(NoDuplicateGeneratorsInBlock) {
|
||||
|
@ -25,8 +25,6 @@
|
||||
// (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: --noharmony-for-in
|
||||
|
||||
function props(x) {
|
||||
var array = [];
|
||||
for (var p in x) array.push(p);
|
||||
@ -141,6 +139,13 @@ function props(x) {
|
||||
(function forInInitialize() {
|
||||
for (var hest = 'hest' in {}) { }
|
||||
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() {
|
||||
|
@ -1,9 +0,0 @@
|
||||
// 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);
|
Loading…
Reference in New Issue
Block a user