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?
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.
PR: https://github.com/dlang/dmd/pull/8358
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17818 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB