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: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Alex <[email protected]> 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: -------