diff --git a/std/parallelism.d b/std/parallelism.d index 51d322172d0..3207bb56d9b 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -3500,7 +3500,7 @@ int doSizeZeroCase(R, Delegate)(ref ParallelForeach!R p, Delegate dg) { res = dg(elem); } - if (res) foreachErr(); + if (res) break; index++; } } @@ -3516,10 +3516,11 @@ int doSizeZeroCase(R, Delegate)(ref ParallelForeach!R p, Delegate dg) { res = dg(elem); } - if (res) foreachErr(); + if (res) break; index++; } } + if (res) foreachErr; return res; } } @@ -4624,3 +4625,12 @@ version(unittest) arr.parallel.each!"a++"; }))); } + +// https://issues.dlang.org/show_bug.cgi?id=17539 +@system unittest +{ + import std.random : rndGen; + // ensure compilation + try foreach (rnd; rndGen.parallel) break; + catch (ParallelForeachError e) {} +}