copying const
Freddy via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 24 12:41:52 PDT 2015
I was surprised when this happened, is it a bug or a feature?
---
struct A
{
const int var;
}
int test()
{
auto b = A(5);
auto c = A(7);
pragma(msg, typeof(b)); //A
pragma(msg, typeof(c)); //A
auto d = b; //compiles
b = c; //doesn't compile
}
---
$ rdmd -main -unittest test
A
A
test.d(13): Error: cannot modify struct b A with immutable members
Failed: ["dmd", "-main", "-unittest", "-v", "-o-", "test.d",
"-I."]
More information about the Digitalmars-d
mailing list