[Issue 3557] Pure function cannot call struct constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 11 13:33:42 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3557
--- Comment #2 from Tomasz Sowiński <tomeksowi at 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: -------
More information about the Digitalmars-d-bugs
mailing list