www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2375] New: Error using invariant array initializers with indexed elements

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

           Summary: Error using invariant array initializers with indexed
                    elements
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


May be duplicate of http://d.puremagic.com/issues/show_bug.cgi?id=1253

Marking it critical as the only workaround I've found is dupping the array,
which is not acceptable.

enum int[] a = [1 : 1];

void main()
{
    auto e = a[0];
}
----
Error: array initializers as expressions are not allowed (x4)


-- 
Sep 26 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2375


samukha voliacable.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical




-- 
Sep 26 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2375





------- Comment #1 from terranium yandex.ru  2008-09-30 04:04 -------
workaround

invariant int[2] a = [1:1];


-- 
Sep 30 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2375





------- Comment #2 from samukha voliacable.com  2008-10-01 07:34 -------
works, thanks


-- 
Oct 01 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2375


bugzilla digitalmars.com changed:

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




------- Comment #3 from bugzilla digitalmars.com  2008-10-02 04:14 -------
The error message is correct, and so is the workaround. Not a bug, though the
array initializer syntax should be improved.


-- 
Oct 02 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2375





------- Comment #4 from terranium yandex.ru  2008-10-02 09:59 -------
I've turned bug 1253 into tracker of struct/array initializers syntax issues.
Or should we open a tracker explicitly?


-- 
Oct 02 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2375





------- Comment #5 from samukha voliacable.com  2008-10-03 03:14 -------
 Not a bug, though the
 array initializer syntax should be improved.

May I ask what's wrong with the syntax? Also, since I can't remember when the compiler has been issuing duplicate error messages, which is a big stress factor :) --
Oct 03 2008