WTF does "Enforcement failed" actually mean?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Sep 30 23:35:30 PDT 2015
On 09/30/2015 10:46 PM, Russel Winder via Digitalmars-d-learn wrote:
> I have the code:
>
> reduce!"a+b"(x)
>
> where x is a int[] and I get an exception "Enforcement failed" at run
> time. This gives me enough information to say ¿que?
>
It's coming from the following no-message enforce():
enforce(!r.empty);
https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm/iteration.d#L2481
You are using the no-seed version of reduce(), which uses the first
element as seed, which means that the range cannot be empty.
Ali
More information about the Digitalmars-d-learn
mailing list