[Issue 7808] New: Nullable's alias this does not work with structs containing classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 1 22:18:26 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7808

           Summary: Nullable's alias this does not work with structs
                    containing classes
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jmdavisProg at gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-04-01 22:18:58 PDT ---
This code compiled just fine with 2.058

import std.typecons;

void main()
{
    auto s = Nullable!S(S(new C));
    func(s);
}

class C
{
}

struct S
{
    C c;

    this(C c)
    {
        this.c = c;
    }
}

void func(S s)
{
}


But it fails to compile with the latest dmd, giving the error

q.d(6): Error: function q.func (S s) is not callable using argument types
(Nullable!(S))
q.d(6): Error: cannot implicitly convert expression (s) of type Nullable!(S) to
S

It works if the member variable is an int or string. It works if the member
variable is a struct type which does _not_ have a class as a member variable.
But if the struct has a member variable which is a class, or it has a member
variable which is a struct which has a member variable which is a class, then
it fails.

Nullable!S' alias this should convert it to an S when passed to func, but it
doesn't when S contains a member variable which is a class - either directly or
indirectly.

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


More information about the Digitalmars-d-bugs mailing list