Comment #0 by bearophile_hugs — 2015-01-11T18:27:19Z
From the first error message it seems "joiner" is @nogc, but the second error message shows that it's the iteration of r1 (calling its .front) non-@nogc:
void main() {
import std.range: iota;
import std.algorithm: map, joiner;
static foo(in uint n) @nogc {
auto r1 = n.iota.map!(x => x.iota.map!(y => x));
auto r2 = r1.joiner;
foreach (z; r1) {}
}
}
test.d(6,21): Error: @nogc function 'test.main.foo' cannot call non-@nogc function 'std.algorithm.joiner!(MapResult!(__lambda2, Result)).joiner'
test.d(7,9): Error: @nogc function 'test.main.foo' cannot call non-@nogc function 'test.main.foo.MapResult!(__lambda2, Result).MapResult.front'
I'd like error messages to better pinpoint where the non-@nogc actually is. Because with library functions like "joiner" you know they are designed to be @nogc, but with user-written ranges it's harder to find where the problem is.
See also Issue 12829
Comment #1 by k.hara.pg — 2016-01-31T14:04:53Z
This code has been changed to being fully inferred to @nogc from 2.068, so today no @nogc violation errors happen with the example case. And, the diagnostic improvement is done in master, by fixing issue 12829.
Mark as resolved-worksforme.