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."]

Reply via email to