Bug 19273 – immutable on a class declaration doesn't cause references of that type to be immutable
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Other
Creation time
2018-09-28T09:30:39Z
Last change time
2018-09-28T09:50:25Z
Assigned to
No Owner
Creator
Jacob Carlborg
Comments
Comment #0 by doob — 2018-09-28T09:30:39Z
This issue is best describe by an example:
immutable struct Foo {}
immutable class Bar {}
void main()
{
Foo foo;
Bar bar;
static assert(is(typeof(foo) == immutable(Foo)));
static assert(is(typeof(bar) == Bar));
}
I don't expect the above code to compile, but it does. The question is why the type of "bar" is not immutable(Bar) when that's the case for "foo"? DMD 2.082.0.
Comment #1 by razvan.nitu1305 — 2018-09-28T09:50:25Z
*** This issue has been marked as a duplicate of issue 18977 ***