Comment #0 by bearophile_hugs — 2014-10-25T15:46:06Z
void main() @nogc {
import std.algorithm: enumerate;
int[1] arr;
auto r = arr[].enumerate;
}
DMD 2.067alpha gives:
test.d(4,19): Error: @nogc function 'D main' cannot call non-@nogc function 'std.range.enumerate!(uint, int[]).enumerate'
Comment #1 by bearophile_hugs — 2015-01-10T17:17:53Z
A possible solution is to replace this:
auto enumerate(Enumerator = size_t, Range)(Range range, Enumerator start = 0)
if (isIntegral!Enumerator && isInputRange!Range)
...
if (overflow || result > Enumerator.max)
throw new RangeError("overflow in `start + range.length`");
}
}
...
With this:
auto enumerate(Enumerator = size_t, Range)(Range range, Enumerator start = 0) @nogc
if (isIntegral!Enumerator && isInputRange!Range)
...
if (overflow || result > Enumerator.max) {
static immutable err = new RangeError("overflow in `start + range.length`");
throw err;
}
}
}
...
But I don't know if immutable errors are really correct.