www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10672] New: struct initializer treated as lambda literal

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

           Summary: struct initializer treated as lambda literal
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: public dicebot.lv


--- Comment #0 from Dicebot <public dicebot.lv> 2013-07-19 04:29:45 PDT ---
Confusing example that breaks "looks like C, acts like C" rule.

----------------------------

struct foo {
    int i;
};

foo[] blah = [ { 1 }, { 2 } ]; // fine

void main()
{
    foo[] blah = [ { 1 }, { 2 } ]; // Error: array initializers as expressions
are not allowed
}

----------------------------

This probably happens because assigning a lambda literal has higher precedence
in grammar than struct initializer. However, difference between global
initialization with forced compile-time evaluation and normal initialization
should be extremely confusing. Especially for people coming from C/C++.

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


Henning Pohl <henning still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |henning still-hidden.de


--- Comment #1 from Henning Pohl <henning still-hidden.de> 2013-07-23 15:47:39
PDT ---
I'm unable to reproduce it. Which platform are you on?

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


Infiltrator <lt.infiltrator gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lt.infiltrator gmail.com


--- Comment #2 from Infiltrator <lt.infiltrator gmail.com> 2013-07-23 17:22:48
PDT ---
I can reproduce on http://dpaste.dzfl.pl/ only with D1; not with D2.

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


Dicebot <public dicebot.lv> changed:

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


--- Comment #3 from Dicebot <public dicebot.lv> 2013-07-24 01:11:05 PDT ---
Yeah, sorry for the fuss, must be inattention from my side.

Closing.

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