www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3927] New: array.length++; is an error

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927

           Summary: array.length++; is an error
           Product: D
           Version: 2.041
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



With the following D2 program:

void main() {
     int[] array;
     array.length++;
     array.length--;
}


The compiler shows the following errors, is this correct?
test1.d(3): Error: a.length is not an lvalue
test1.d(4): Error: a.length is not an lvalue

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 10 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |clugdbug yahoo.com.au
            Summary|array.length++; is an error |array.length++; is an
                   |                            |error, but ++array.length
                   |                            |compiles



++array.length;
compiles. The bizarre error is because of the lowering that the compiler uses
internally.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
            Version|2.041                       |D1 & D2
         AssignedTo|nobody puremagic.com        |yebblies gmail.com
         OS/Version|Windows                     |All



https://github.com/D-Programming-Language/dmd/pull/681

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/38c9dcde7b25415adf6a1ef2f3eddd83af3a59a8
fix Issue 3927 - array.length++; is an error, but ++array.length compiles

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2012
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com
            Version|D1 & D2                     |D1



01:31:32 PST ---
Fixed for D2 only.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2012
parent reply "Salih Dincer" <bearophile_hugs eml.cc> writes:

 2012-02-22 01:31:32 PST ---
 Fixed for D2 only.
void main() { int[] array = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; writeln(array, "~", --array.length); assert (array.length == 9); } Which one is correct? Best regards...
Feb 22 2012
parent "Salih Dincer" <salihdb hotmail.com> writes:
No problem...

void main() {
     int[] array = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
     writeln(array, "~", ++array.length,
                   "->", --array.length);
     assert (array.length == 10);        // no problem
     writeln(array, "~", array.length);
}

DMD version: 2.057
==================
salih DB-N150-N210-N220:~/d.ders$ ./dene
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~11->10
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~10

Best regards..
Feb 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927


Salih Dincer <salihdb hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |salihdb hotmail.com



---

 Fixed for D2 only.
void main() { int[] array = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; writeln(array, "~", ++array.length, "->", --array.length); assert (array.length == 10); // no problem ++array.length; --array.length; writeln(array, "~", array.length); } DMD version: 2.057 ================== salih DB-N150-N210-N220:~/d.ders$ ./dene [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~11->10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~10 No problem... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 22 2012
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927






 Fixed for D2 only.
void main() { int[] array = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; writeln(array, "~", ++array.length, "->", --array.length); assert (array.length == 10); // no problem ++array.length; --array.length; writeln(array, "~", array.length); } DMD version: 2.057 ================== salih DB-N150-N210-N220:~/d.ders$ ./dene [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~11->10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~10 No problem...
Huh? What's your point? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 22 2012
parent "Salih Dincer" <salihdb hotmail.com> writes:
On Wednesday, 22 February 2012 at 15:01:45 UTC, yebblies wrote:
 DMD version: 2.057
 ==================
 salih DB-N150-N210-N220:~/d.ders$ ./dene
 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~11->10
 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]~10
 
 No problem...
Huh? What's your point?
I'm new learning to java language! Just tried it and I see no problem ...:) I thank you for your interest in my code snippets... Best Regards...
Feb 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927




---
I'm new learning to java language! Just tried it and I see no problem ...:)

I thank you for your interest in my code snippets...

Best Regards...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3927


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
            Version|D1                          |D2
         Resolution|                            |FIXED



Fixed, this was a D2-only bug (on D1, ++arr.length doesn't work either).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 11 2012