const->immutable array argument?

bearophile bearophileHUGS at lycos.com
Tue Sep 20 04:33:20 PDT 2011


In this bug report I have asked for better error messages:
http://d.puremagic.com/issues/show_bug.cgi?id=6696

But beside the error message, do you know why an immutable ref can't be given to a function with a const ref argument? foo() can't change the contents of the array a any way, so what's wrong in this code?


void foo(const ref int[5] a) {}
void main() {
    immutable int[5] arr;
    foo(arr); // Error?
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list