www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10134] New: Mutual referencing templates error

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg 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: -------
May 22 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10134


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-05-22 04:04:33 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2062

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10134



--- Comment #2 from github-bugzilla puremagic.com 2013-05-23 00:54:52 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a60e757ba69e890881480b98a6dba5456832f55f
fix Issue 10134 - Mutual referencing templates error

https://github.com/D-Programming-Language/dmd/commit/9edb35f64c700eca65be718aa057cdc344896836
Merge pull request #2062 from 9rnsr/fix10134

[2.063a] Issue 10134 - Mutual referencing templates error

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10134



--- Comment #3 from github-bugzilla puremagic.com 2013-05-23 00:56:52 PDT ---
Commit pushed to 2.063 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a0292c10efb67931e208e0736f626ad5ef3fe531
Merge pull request #2062 from 9rnsr/fix10134

[2.063a] Issue 10134 - Mutual referencing templates error

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10134


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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