October 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11208

           Summary: returned ref to scoped isn't caught by local ref
                    escape error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: eco@gnuk.net


--- Comment #0 from Brad Anderson <eco@gnuk.net> 2013-10-09 10:02:20 PDT ---
Tested with dmd 2.63.2. Trying to return a ref int to a local int errors correctly as does a `scope A a = new A()`.

---

import std.typecons, std.stdio;

class A { }

// Using auto ref because I don't know how to get the type of scoped
// (I guess I should file this behavior as a bug too)
auto ref fun()
{
    auto a = scoped!A();
    writefln("%x", &a);
    return a; // Compiler should output:
              // Error: escaping reference to scope local a
}

void main()
{
    auto a = fun();
    writefln("%x", &a);
}

---

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