[Issue 10138] New: Regression (2.063 git-head): Using ReturnType with scoped no longer works

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 22 19:38:37 PDT 2013


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

           Summary: Regression (2.063 git-head): Using ReturnType with
                    scoped no longer works
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-05-22 19:38:35 PDT ---
-----
import std.traits;
import std.typecons;

class A
{
}

class B
{
    ReturnType!(scoped!A) a;  // L12

    this()
    {
        a = scoped!A();
    }
}

void main()
{
}
-----

2.062: ok
2.063 git-head:

test.d(12): Error: template instance ReturnType!(scoped) does not match
template declaration ReturnType(func...) if (func.length == 1 &&
isCallable!(func))

This is a breaking change. The workaround is to use 'typeof(scoped!A())'. This
workaround was not documented either.

Note that we should consider moving the inner Voldemort type to be a
module-scoped templated struct (e.g. 'Scoped'), so the API is easier to use if
you use scoped!() for member variables, e.g.:

-----
class B
{
    Scoped!A a;  // better API

    this()
    {
        a = scoped!A();
    }
}
-----

This is all based on the assumption that using scoped for member variables is
something that is supported. There are currently no unittests that try to
declare scoped variables, hence why this should either become an official
feature or it should be properly documented as disallowed.

-- 
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