Comment #0 by bearophile_hugs — 2014-07-11T08:00:33Z
I think all this program should compile:
void main() {
import std.typecons: Tuple, Nullable;
import std.algorithm: cartesianProduct;
string[] a;
const Nullable!(Tuple!(string[])) b;
const string[] c = b.get[0]; // OK
foreach (ab; cartesianProduct(a, c)) {} // OK
foreach (ab; cartesianProduct(a, b[0])) {} // fails
foreach (ab; cartesianProduct(a, b.get[0])) {} // fails
}
With dmd 2.066beta2 it gives:
...\dmd2\src\phobos\std\algorithm.d(12783,10): Error: static assert "cartesianProduct involving finite ranges must have at least one finite forward range"
test.d(8,34): instantiated from here: cartesianProduct!(string[], const(immutable(char)[][]))
Comment #1 by hsteoh — 2014-07-12T15:02:15Z
Weird, seems b[0] and b.get[] must be returning some kind of proxy type, since passing const(string[]) to cartesianProduct works just fine. Either that, or this is a compiler bug that somehow messes up type inference. Will have to investigate a bit more to figure it out.
Comment #2 by robert.schadek — 2024-12-01T16:21:48Z