www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11950] New: Weird bracket behavior in delegates

https://d.puremagic.com/issues/show_bug.cgi?id=11950

           Summary: Weird bracket behavior in delegates
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: czdanol gmail.com


--- Comment #0 from Daniel ─îejchan <czdanol gmail.com> 2014-01-19 06:39:09 PST
---
import std.stdio;
import std.conv;

//version = right;

struct A {
    int val = 3;
};


void main() {
    void delegate( A ) Ptr;

    Ptr = ( a ) {
        version( right )
        writefln( a.val.to!string ); 
        else
        writefln( ( a.val ).to!string ); 
    };

    A i;

    Ptr( i );
}

Code with writefln( ( a.val ).to!string ); causes an error (Error: need 'this'
for 'val' of type 'int'), the second one doesn't.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 19 2014