struct A { int a; }
void g()
{
shared A a;
A b;
a=b; //converts
assert(a==b); //fail
}
Error: incompatible types for ((a) is (b)): 'shared(A)' and 'A'
Works for immutable. Is it an oversight?
Comment #1 by dunkyp — 2017-10-02T15:36:58Z
I don't think this is an oversight. The table at https://dlang.org/spec/const3.html in section 18.11 says that shared cannot be implicitly converted to mutable. The same code as yours with b marked immutable works. I do think this behaviour is a little surprising.
Comment #2 by razvan.nitu1305 — 2018-06-14T13:41:46Z