[Issue 10134] New: Mutual referencing templates error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 22 03:52:59 PDT 2013


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

           Summary: Mutual referencing templates error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-05-22 03:52:57 PDT ---
With git head, the following code reports these errors.

test.d(22): Error: template instance
Result!(__T13getResultTypeS124test6__T1aZZ) does not match template declaration
Result(T)
test.d(40): Error: template instance test.f!(__T1aZ) error instantiating
test.d(32):        instantiated from here: b!()
test.d(44):        instantiated from here: a!()
test.d(32): Error: template instance test.b!() error instantiating
test.d(44):        instantiated from here: a!()
test.d(44): Error: template instance test.getResultType!(__T1aZ) error
instantiating
test.d(44):        while evaluating pragma(msg, getResultType!(__T1aZ))

But with 2.062, it compiles successfully and prints 'double'.

//import std.traits : ReturnType;
template ReturnType(alias func)
{
    static if (is(typeof(func) R == return))
        alias R ReturnType;
    else
        static assert(0);
}

struct Result(T){}

template getResultType(alias func)
{
    static if(is(ReturnType!(func.exec) == Result!(T), T))
    {
        alias getResultType = T;
    }
}

template f(alias func)
{
    Result!(getResultType!(func)) exec(int i)
    {
        return typeof(return)();
    }
}

template a()
{
    Result!(double) exec(int i)
    {
        return b!().exec(i);
    }
}

template b()
{
    Result!(double) exec(int i)
    {
        return f!(a!()).exec(i);
    }
}

pragma(msg, getResultType!(a!()));

void main(){}

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