Skip to content

Commit

Permalink
Couldn't remove mobules without translation unit (#1861)
Browse files Browse the repository at this point in the history
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.

Co-authored-by: HenrikVDestia <henrik.valve@destia.fi>
  • Loading branch information
HenrikAkseliValve and HenrikVDestia authored Aug 20, 2024
1 parent b658ff3 commit 345de8b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Generator/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ public static bool Run(ILibrary library)
}

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

if (!options.Quiet)
Diagnostics.Message("Processing code...");
Expand Down

0 comments on commit 345de8b

Please sign in to comment.