www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10843] New: Combinatorial problem of struct & alias this & null

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

           Summary: Combinatorial problem of struct & alias this & null
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: zan77137 nifty.com



These tree samples don't work:
------------------
unittest
{
    static struct HANDLE
    {
        void* h;
        alias h this;
    }

    //HANDLE a = null;             // NG
    HANDLE a;
    a = null;                      // OK
}

unittest
{
    static struct HANDLE
    {
        void* h;
        alias h this;
        this(void* h) { this.h = h; }
    }
    HANDLE a = null;               // OK
    static void foo(HANDLE h){}
    //foo(null);                   // NG
}

unittest
{
    static struct HANDLE
    {
        void* h;
        alias h this;
        this(void* h) { this.h = h; }
    }
    static struct WSAEVENT
    {
        HANDLE h;
        alias h this;
        this(HANDLE h) { this.h = h; }
    }
    auto a = cast(HANDLE)null;     // OK
    //auto b = cast(WSAEVENT)null; // NG
}

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |maxim maxim-fomin.ru
         Resolution|                            |INVALID



---
This is invalid report in all there cases.

1) is implicit construction for which constructor with respective arguments
should be defined (as provided in second example). 

2) is implicit construction on argument passing for which variardic functions
do exists. Spec is explicit that for such cases ctor is required.



This is compilable:
unittest
{
    static struct HANDLE
    {
        void* h;
        alias h this;
    }

    //HANDLE a = null;             // NG
    HANDLE a;
    a = null;                      // OK
}

unittest
{
    static struct HANDLE
    {
        void* h;
        alias h this;
        this(void* h) { this.h = h; }
    }
    HANDLE a = null;               // OK
    static void foo(HANDLE h ...){}
    foo(null);                   // OK
}

unittest
{
    static struct HANDLE
    {
        void* h;
        alias h this;
        this(void* h) { this.h = h; }
    }
    static struct WSAEVENT
    {
        HANDLE h;
        alias h this;
        this(HANDLE h ...) { this.h = h; }
    }
    auto a = cast(HANDLE)null;     // OK
    auto b = cast(WSAEVENT)null; // OK
}

void main() {}

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