www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2813] New: implicit cast (implemented via alias this) is not triggered when returning from function

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

           Summary: implicit cast (implemented via alias this) is not
                    triggered when returning from function
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: 2korden gmail.com


struct Proxy
{
        private Object o;

        Object get() { return o; }

        alias get this;
}

class Bar
{
        Object getObject()
        {
                //return _proxy; // should work, but doesn't

                Object o = _proxy;
                return o; // works but not like intended
        }

        private Proxy _proxy;
}

test.d(14): Error: cannot implicitly convert expression (this._proxy) of type
Proxy to object.Object


-- 
Apr 06 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2813


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2011-05-24
22:26:46 PDT ---
Works in 2.053:

struct Proxy
{
    private Object o;
    Object get() { return o; }
    alias get this;
}

class Bar
{
    Object getObject()
    {
        return _proxy; // should work, but doesn't
    }

    private Proxy _proxy;
}

void main()
{
    auto bar = new Bar();

    auto proxy = bar.getObject();
    assert(proxy is null);
}

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