[Issue 6797] Fake changes to enum array of array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 1 15:07:38 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6797
SomeDude <lovelydear at mailmetrash.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lovelydear at mailmetrash.com
--- Comment #1 from SomeDude <lovelydear at mailmetrash.com> 2012-05-01 15:08:48 PDT ---
This simpler case actually fails:
void main() {
enum int[] array = [2, 1];
foreach (r; array){
r *= 10; // should be rejected
writeln(array);
}
foreach (ref r; array){
r *= 10; // should be rejected
writeln(array);
}
assert(array == [20, 10]);
}
Changing enum to immutable gives the following compilation errors:
bug.d(8): Error: variable bug.main.r cannot modify immutable
bug.d(12): Error: variable bug.main.r cannot modify const
But this
void main() {
enum int[] array = [2, 1];
array[0] = 5;
}
is correctly caught by the compiler:
bug.d(7): Error: constant [2,1][0] is not an lvalue
--
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