http://d.puremagic.com/issues/show_bug.cgi?id=10424
Kenji Hara <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Kenji Hara <[email protected]> 2013-06-20 18:39:14 PDT --- (In reply to comment #0) > int f(); > int[] g(); > void main() > { > //f() = 42; // as expected: Error: f() is not an lvalue > //g() = [42]; // as expected: Error: g() is not an lvalue > g()[] = [42]; // compiles, but shouldn't > } The line is correct D code. g() returns an rvalue int[] array, but the assignment is element-wise, and elements of array are always lvalue. Then, there's no meaningless rvalue modification. void main() { int[] a = [1]; int[] arr = a; int[] g() { return arr; } g()[] = [42]; // element-wise assignment // essentially same as: // int[] x = [42]; arr[] = x[]; assert(arr.ptr == a.ptr); assert(arr == [42]); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
