Commit 7b9d6bbc authored by hablich's avatar hablich Committed by Commit bot

Revert of [modules] Make duplicate export error deterministic. (patchset #2...

Revert of [modules] Make duplicate export error deterministic. (patchset #2 id:20001 of https://codereview.chromium.org/2331003002/ )

Reason for revert:
Seems to break one of our arm64 bots: https://chromegw.corp.google.com/i/client.v8.ports/builders/V8%20Linux%20-%20arm64%20-%20sim%20-%20nosnap%20-%20debug/builds/2303

Original issue's description:
> [modules] Make duplicate export error deterministic.
>
> In case of duplicate exports, always report the error for the very last
> one.
>
> R=adamk@chromium.org
> BUG=v8:5358,v8:1569
>
> Committed: https://crrev.com/da1f911c4269048d24a3442791b18523455f3b24
> Cr-Commit-Position: refs/heads/master@{#39424}

TBR=adamk@chromium.org,neis@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5358,v8:1569

Review-Url: https://codereview.chromium.org/2340903002
Cr-Commit-Position: refs/heads/master@{#39430}
parent 2a469905
......@@ -136,30 +136,17 @@ void ModuleDescriptor::MakeIndirectExportsExplicit(Zone* zone) {
const ModuleDescriptor::Entry* ModuleDescriptor::FindDuplicateExport(
Zone* zone) const {
const ModuleDescriptor::Entry* candidate = nullptr;
ZoneSet<const AstRawString*> export_names(zone);
for (const auto& it : regular_exports_) {
const Entry* entry = it.second;
DCHECK_NOT_NULL(entry->export_name);
DCHECK(entry->location.IsValid());
bool is_duplicate = !export_names.insert(entry->export_name).second;
if (is_duplicate &&
(candidate == nullptr ||
entry->location.beg_pos > candidate->location.beg_pos)) {
candidate = entry;
}
if (!export_names.insert(entry->export_name).second) return entry;
}
for (auto entry : special_exports_) {
if (entry->export_name == nullptr) continue; // Star export.
DCHECK(entry->location.IsValid());
bool is_duplicate = !export_names.insert(entry->export_name).second;
if (is_duplicate &&
(candidate == nullptr ||
entry->location.beg_pos > candidate->location.beg_pos)) {
candidate = entry;
}
if (!export_names.insert(entry->export_name).second) return entry;
}
return candidate;
return nullptr;
}
bool ModuleDescriptor::Validate(ModuleScope* module_scope,
......
......@@ -151,8 +151,8 @@ class ModuleDescriptor : public ZoneObject {
ZoneMultimap<const AstRawString*, Entry*> regular_exports_;
ZoneMap<const AstRawString*, const Entry*> regular_imports_;
// If there are multiple export entries with the same export name, return the
// last of them (in source order). Otherwise return nullptr.
// If there are multiple export entries with the same export name, return one
// of them. Otherwise return nullptr.
const Entry* FindDuplicateExport(Zone* zone) const;
// Find any implicitly indirect exports and make them explicit.
......
......@@ -4,6 +4,6 @@
//
// MODULE
var a, b, c;
var a, b;
export { a as c };
export { a, b as c, c, b };
export { a, b as c };
......@@ -2,6 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
*%(basename)s:9: SyntaxError: Duplicate export of 'c'
export { a, b as c, c, b };
^
export { a, b as c };
^
SyntaxError: Duplicate export of 'c'
......@@ -5,5 +5,4 @@
// MODULE
export default function f() {};
export default 42;
export default class C {};
# 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.
*%(basename)s:9: SyntaxError: Duplicate export of 'default'
*%(basename)s:8: SyntaxError: Duplicate export of 'default'
export default class C {};
^^^^^^^
SyntaxError: Duplicate export of 'default'
......@@ -4,7 +4,6 @@
//
// MODULE
var a, b, c;
var a, b;
export { a };
export { a, b };
export { b, c };
# 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.
*%(basename)s:10: SyntaxError: Duplicate export of 'b'
export { b, c };
*%(basename)s:9: SyntaxError: Duplicate export of 'a'
export { a, b };
^
SyntaxError: Duplicate export of 'b'
SyntaxError: Duplicate export of 'a'
......@@ -31,5 +31,7 @@
# escapes (we need to parse to distinguish octal escapes from valid
# back-references).
'strict-octal-regexp': [SKIP],
# See issue v8:5358
'export-duplicate-default': [SKIP],
}], # ALWAYS
]
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