[Issue 3557] Pure function cannot call struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=3557 --- Comment #2 from Tomasz Sowiński tomeks...@gmail.com 2010-01-11 13:33:40 PST --- (In reply to comment #1) It shouldn't compile, since the constructor isn't marked as pure. But if you mark the constructor as pure: pure { this (float f) { this.f = f; } } you get: bug.d(14): Error: cannot modify const/immutable/inout expression this.f So we definitely have a problem. Yes, I had a feeling compiler should let me have pure ctors.. What about the problem I mentioned at the bottom (if A is a class): class A { float f; this (float f) {// NOT pure this.f = f; } static pure A stworz(float f) { return new A(f); } } This compiles. Should it? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3557] Pure function cannot call struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=3557 --- Comment #3 from Tomasz Sowiński tomeks...@gmail.com 2010-01-11 13:40:33 PST --- (In reply to comment #2) This compiles. Should it? I'm now confident it shouldn't: string global; class A { float f; this (float f) {// NOT pure this.f = f; global = BUGABUGA!; } static pure A stworz(float f) { return new A(f); } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3557] Pure function cannot call struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=3557 Don clugd...@yahoo.com.au changed: What|Removed |Added Keywords||rejects-valid CC||clugd...@yahoo.com.au --- Comment #1 from Don clugd...@yahoo.com.au 2010-01-10 11:54:44 PST --- It shouldn't compile, since the constructor isn't marked as pure. But if you mark the constructor as pure: pure { this (float f) { this.f = f; } } you get: bug.d(14): Error: cannot modify const/immutable/inout expression this.f So we definitely have a problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---