[Issue 11346] [2.064 beta] field initializing not allowed in loops or after labels
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 25 00:10:48 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11346
--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-25 00:10:47 PDT ---
(In reply to comment #2)
> That is so non intuitive. A good example how you can make simple code more
> complicated. I will wait for the threads in D.learn or possible bug reports for
> that...
If multiple initialization for non-mutable field is allowed, it could break
type system. For example:
struct S {
const int[] arr;
this(immutable int[] a) {
arr = a; // First initialization
arr[0] = 1; // Second initialization - modify immutable data!
}
}
Therefore, it's necessary limitation.
--
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