www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11316] New: Some cases of missing delegate argument type inference

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

           Summary: Some cases of missing delegate argument type inference
           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-10-21 11:26:22 PDT ---
void main() {
    void delegate(const int x) F0;
    F0 = (const int x) {}; // OK
    F0 = (x) {};           // OK
    void delegate(in int x) F1;
    F1 = (in int x) {};    // OK
    F1 = (x) {};           // OK
    void delegate(ref int x) F2;
    F2 = (ref int x) {};   // OK
    F2 = (x) {};           // Error
    void delegate(out int x) F3;
    F3 = (out int x) {};   // OK
    F3 = (x) {};           // Error
}



dmd 2.064beta2 gives:

test.d(10): Error: cannot implicitly convert expression (__lambda6) of type
void delegate(int x) pure nothrow  safe to void delegate(ref int x)
test.d(13): Error: cannot implicitly convert expression (__lambda8) of type
void delegate(int x) pure nothrow  safe to void delegate(out int x)

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


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim maxim-fomin.ru> 2013-10-21 12:06:20 PDT
---
I think parameter attribute should be provided for explicitly stating that
parameter 'x' will be passed in a specific way, so the fact that 

    void delegate(ref int x) F2;
    F2 = (ref int x) {};   // OK
    F2 = (x) {};           // Error
    void delegate(out int x) F3;
    F3 = (out int x) {};   // OK
    F3 = (x) {};           // Error

is rejected may be a good thing (my guess why first examples are compiled is
because qualifiers and attributes are trated separately, and 'in' is alias for
'const'). On the other hand, probably having attribute only in variable
declaration is enough and such bahavior may have value for generic programming.

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