www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 500] New: Cannot assign to delegate during definition

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

           Summary: Cannot assign to delegate during definition
           Product: D
           Version: 0.173
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: marsell_pk yahoo.com


This compiles:
  void delegate() y;
  y = { ... };

This does not:
  void delegate() y = { ... };

For example:
  void main() {
  //      void delegate() y = { return; };
        void delegate() y;
        y = { return; };
        x(y);
  }

  void x(void delegate() y) {
    y();
  }


-- 
Nov 13 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=500






Not sure it's a bug, that error is because of syntax conflict with struct
initializers (http://www.digitalmars.com/d/struct.html). It's a limitation that
might or might not be fixable, I dunno. (It does seem possible for the grammar
to differentiate

Meanwhile, a workaround:
  void delegate() y = ({ return; });


-- 
Nov 14 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=500







 Not sure it's a bug, that error is because of syntax conflict with struct
 initializers (http://www.digitalmars.com/d/struct.html). It's a limitation that
 might or might not be fixable, I dunno. (It does seem possible for the grammar
 to differentiate
The only cases parseable as either a struct init or a function/delegate body are { } { { } } { { { } } } and so on. Otherwise, it's obvious whether a { ... } contains expressions or statements. --
Nov 14 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=500


deewiant gmail.com changed:

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





Fixed in DMD 0.176.


-- 
Dec 03 2006
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-11-13:
 http://d.puremagic.com/issues/show_bug.cgi?id=500
 This compiles:
   void delegate() y;
   y = { ... };

 This does not:
   void delegate() y = { ... };

 For example:
   void main() {
   //      void delegate() y = { return; };
         void delegate() y;
         y = { return; };
         x(y);
   }

   void x(void delegate() y) {
     y();
   }
Added to DStress as http://dstress.kuehne.cn/run/d/delegate_20_A.d http://dstress.kuehne.cn/run/d/delegate_20_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFjZaZLK5blCcjpWoRAqsiAJ9/4pC/TdF31L5Ddjgbew7wgEoa9gCfZ6TM lC/v1sZnTumCoR98ZEI59Rc= =UG0N -----END PGP SIGNATURE-----
Dec 23 2006