Skip to content

Commit 6f017a9

Browse files
committed
Couldn't remove mobules without translation unit
I do not know I'm first to encounter this, however, loop that removes module without translation units, could not have worked. In C# Enumerator prohibs editing the collection so you cannot remove modules from `options.Module` while iterating `options.Mobule`. Chose `RemoveAll` for its simplicity. Not necessary optimal solution although it might be.
1 parent b658ff3 commit 6f017a9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Generator/Driver.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,12 @@ public static bool Run(ILibrary library)
417417
}
418418

419419
new CleanUnitPass { Context = driver.Context }.VisitASTContext(driver.Context.ASTContext);
420-
foreach (var module in options.Modules.Where(
421-
m => m != options.SystemModule && !m.Units.GetGenerated().Any()))
420+
options.Modules.RemoveAll(m =>
422421
{
423-
Diagnostics.Message($"Removing module {module} because no translation units are generated...");
424-
options.Modules.Remove(module);
425-
}
422+
bool result = m != options.SystemModule && !m.Units.GetGenerated().Any();
423+
if (result) Diagnostics.Message($"Removing module {m} because no translation units are generated...");
424+
return result;
425+
});
426426

427427
if (!options.Quiet)
428428
Diagnostics.Message("Processing code...");

0 commit comments

Comments
 (0)