http://d.puremagic.com/issues/show_bug.cgi?id=11343
bearophile_h...@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_h...@eml.cc --- Comment #7 from bearophile_h...@eml.cc 2013-10-28 15:19:49 PDT --- (In reply to comment #5) > A const reference may refer immutable data which comes from the out of the > constructor. If so, modifying const data inside constructor is definitely > illegal operation. By disallowing multiple initialization, compiler can > validate the field initializing correctness or not, at the first initializing > place. To reduce a little the disruption of formerly compilable code is it possible and a good idea to make the detector smarter, and allow code like this? struct Foo { immutable int[3] arr; this(int x) { arr[0] = x; arr[1] = x + 1; arr[2] = x + 2; } } void main() { auto f = Foo(5); } Currently it gives: test.d(5): Error: multiple field arr initialization test.d(6): Error: multiple field arr initialization The idea is to see and track every cell of a fixed-size array as an independent variable, like this, that compiles: struct Foo { immutable int arr0, arr1, arr2; this(int x) { arr0 = x; arr1 = x + 1; arr2 = x + 2; } } void main() { auto f = Foo(5); } If this is possible and good, then I could open an enhancement request on this. (Once that's possible, in future we could even allow some simple forms of initialization in loops, but that's for later). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------