Comment #0 by bearophile_hugs — 2014-07-10T22:10:01Z
void main() pure nothrow @safe @nogc {
import std.algorithm: cartesianProduct;
int[1] a = [1];
foreach (t; cartesianProduct(a[], a[])) {}
}
dmd 2.066beta2 gives me:
test.d(4,33): Error: pure function 'D main' cannot call impure function 'std.algorithm.cartesianProduct!(int[], int[]).cartesianProduct'
test.d(4,33): Error: @nogc function 'D main' cannot call non-@nogc function 'std.algorithm.cartesianProduct!(int[], int[]).cartesianProduct'
test.d(4,5): Error: pure function 'D main' cannot call impure function 'std.algorithm.joiner!(MapResult!(__lambda3, int[])).joiner.Result.popFront'
test.d(4,5): Error: @nogc function 'D main' cannot call non-@nogc function 'std.algorithm.joiner!(MapResult!(__lambda3, int[])).joiner.Result.popFront'
test.d(4,33): Error: 'std.algorithm.cartesianProduct!(int[], int[]).cartesianProduct' is not nothrow
test.d(4,5): Error: 'std.algorithm.joiner!(MapResult!(__lambda3, int[])).joiner.Result.popFront' is not nothrow
test.d(1,6): Error: function 'D main' is nothrow yet may throw
Comment #3 by bearophile_hugs — 2014-09-19T11:35:33Z
Thank you.
Do you know the cause of this problem?
void main() @safe {
import std.algorithm: cartesianProduct;
import std.array: array;
const r = cartesianProduct([1], [1]).array;
}
test.d(4,41): Error: safe function 'D main' cannot call system function 'std.array.array!(Result).array'