Jump to page: 1 2
Thread overview
[Issue 3927] New: array.length++; is an error
[Issue 3927] array.length++; is an error, but ++array.length compiles
Feb 01, 2012
Don
Feb 01, 2012
yebblies
Feb 22, 2012
Walter Bright
Feb 22, 2012
Salih Dincer
Feb 22, 2012
Salih Dincer
Feb 22, 2012
Salih Dincer
Feb 22, 2012
yebblies
Feb 22, 2012
Salih Dincer
Feb 22, 2012
Salih Dincer
Apr 11, 2012
Don
March 10, 2010
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


--- Comment #0 from bearophile_hugs@eml.cc 2010-03-10 10:12:01 PST ---
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: -------
February 01, 2012
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


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-02-01 04:27:31 PST ---
++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: -------
February 01, 2012
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


--- Comment #2 from yebblies <yebblies@gmail.com> 2012-02-02 03:32:09 EST ---
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: -------
February 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3927



--- Comment #3 from github-bugzilla@puremagic.com 2012-02-22 01:31:11 PST ---
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: -------
February 22, 2012
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


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2012-02-22 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: -------
February 22, 2012
> --- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 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...

February 22, 2012
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..

February 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3927


Salih Dincer <salihdb@hotmail.com> changed:

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


--- Comment #5 from Salih Dincer <salihdb@hotmail.com> 2012-02-22 06:45:38 PST ---
(In reply to comment #4)
> 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: -------
February 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3927



--- Comment #6 from yebblies <yebblies@gmail.com> 2012-02-23 02:01:42 EST ---
(In reply to comment #5)
> (In reply to comment #4)
> > 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: -------
February 22, 2012
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...
« First   ‹ Prev
1 2