digitalmars.D.bugs - [Issue 7981] New: immutable structs by default have mutable constructor
- d-bugmail puremagic.com (30/30) Apr 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7981
http://d.puremagic.com/issues/show_bug.cgi?id=7981 Summary: immutable structs by default have mutable constructor Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: malicious.wizard gmail.com --- Comment #0 from Alex <malicious.wizard gmail.com> 2012-04-24 13:34:32 PDT --- Consider following code: immutable struct Foo { this(int) { } void bar() { } } int main(in string[] args) { auto foo = Foo(1); foo.bar(); } This will not work out, because `bar()` is immutable, but `foo` is not. If constructor is declared as `this(int) immutable {}`, it will work again. Default no-arg constructor for immutable structs is already immutable, so shouldn't other constructor also be considered immutable implicitly, much like methods are? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 24 2012