Chris Williams:

Range is not castable to array. See std.array.array to generate an array from a Range.


Currently this program:

void main() {
    import std.range;
    int[] a = iota(10);
}


Gives an error like:

test.d(3,19): Error: cannot implicitly convert expression (iota(10)) of type Result to int[]


For the error message to be like yours, the compiler has to recognize a Range, this could be possible because foreach() already does that.

I think you can try to open a diagnostic enhancement request.

In D there are already examples of hardcoded error messages targeting newbies:

void main() {
    int x;
    writeln(a);
    printf("%d\n", x);
}


Gives:

test.d(3,5): Error: 'writeln' is not defined, perhaps you need to import std.stdio; ? test.d(4,5): Error: 'printf' is not defined, perhaps you need to import core.stdc.stdio; ?

Bye,
bearophile

Reply via email to