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

Unified Diff: src/objects.cc

Issue 2376563002: [modules] Don't throw when detecting cycle while processing star exports. (Closed)
Patch Set: Created 4 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/objects.h ('k') | test/mjsunit/modules-fail-star-exports-conflict.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 828fcd896a0607ecd52aacfa7f9a0e49080c15bd..92f24391f8d40d1d904df6eac2651b45ad9d4ec3 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -19707,22 +19707,25 @@ MaybeHandle<Cell> Module::ResolveExport(Handle<Module> module,
return Handle<Cell>::cast(object);
}
- // Must be an indirect export of some sort, so we need to detect cycles.
+ // Check for cycle before recursing.
{
// Attempt insertion with a null string set.
auto result = resolve_set->insert({module, nullptr});
UnorderedStringSet*& name_set = result.first->second;
- bool did_insert = result.second;
- if (did_insert) {
+ if (result.second) {
// |module| wasn't in the map previously, so allocate a new name set.
Zone* zone = resolve_set->zone();
name_set =
new (zone->New(sizeof(UnorderedStringSet))) UnorderedStringSet(zone);
} else if (name_set->count(name)) {
- // TODO(adamk): Throwing here is incorrect in the case of star exports.
- THROW_NEW_ERROR(
- isolate,
- NewSyntaxError(MessageTemplate::kCyclicModuleDependency, name), Cell);
+ // Cycle detected.
+ if (must_resolve) {
+ THROW_NEW_ERROR(
+ isolate,
+ NewSyntaxError(MessageTemplate::kCyclicModuleDependency, name),
+ Cell);
+ }
+ return MaybeHandle<Cell>();
}
name_set->insert(name);
}
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/modules-fail-star-exports-conflict.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698