www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10684] New: Refused array op with array literal

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

           Summary: Refused array op with array literal
           Product: D
           Version: D2
          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 2013-07-20 12:47:14 PDT ---
void main() {
    int[] a = [0, 0];
    a[] += [10, 20][];
}


DMD 2.064alpha gives:

test.d(3): Error: invalid array operation a[] += [10, 20] (did you forget a []
?)


I think this used to work.

Maybe related to Issue 10626

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 20 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10684


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86                         |All
         OS/Version|Windows                     |All
           Severity|normal                      |regression


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-10-16 01:36:32 PDT ---
This is a regression from 2.063.

Introduced commit:
https://github.com/9rnsr/dmd/commit/f703c5c6551affddd9213f759657a2b3e391b935

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10684


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-10-16 03:22:18 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2672

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10684



--- Comment #3 from github-bugzilla puremagic.com 2013-10-17 23:53:19 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f78a770f469fcc60d450e1b9fcd03fbc9ffb010d
fix Issue 10684 - Refused array op with array literal

Accept array literals as the operand of array-ops.

---

Since, array-ops had required explicit slice to the array literal operands,
eg. `a[] = [1,2][] + c[];`

By the commit:
https://github.com/9rnsr/dmd/commit/f703c5c6551affddd9213f759657a2b3e391b935
now the redundant slice operators at the right side of an array literal is
entirely removed - `[1,2,3][][]` is rewritten to `[1,2,3]`.

Although it has broke existing code using array-ops, I still cannot think
the optimization was incorrect.

On the other hand, I could not find the description about the necessity of
explicit slice on array literal from the language spec.
http://dlang.org/arrays.html#array-operations
It looked to me that is just an implementation-specific restriction.

So, I implemented this as the easiest way to fix the issue.

https://github.com/D-Programming-Language/dmd/commit/f39979fde3b2000047c6aae652a42db5572a2a38
Merge pull request #2672 from 9rnsr/fix10684

[REG2.063][enh] Issue 10684 - Refused array op with array literal

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10684



--- Comment #4 from github-bugzilla puremagic.com 2013-10-17 23:54:16 PDT ---
Commit pushed to 2.064 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/94dd0598e660d85e72092adb631843ddff1651c0
Merge pull request #2672 from 9rnsr/fix10684

[REG2.063][enh] Issue 10684 - Refused array op with array literal

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 17 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10684


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 18 2013