Summary: Unreasonable error without line number: "recursive
                    template expansion"
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Norbert Nemec <> 2010-03-02 02:41:04 
PST ---
The code below creates an unreasonable error without a line number. There is no
reason why this kind of finite recursion should not work. Simple workarounds
exist. In any case, the error message should contain a line number to help fix
the problem.

import std.stdio;

struct sum(A,B) {
    A a;
    B b;

    auto opAdd(T)(T a) { return .sum!(sum,T)(this,a); }

struct base {
    auto opAdd(T)(T a) { return .sum!(base,T)(this,a); }

void main() {
    base a,b,c;

    // first a few working examples
    writeln(typeid(a));       // base
    writeln(typeid(a+b));     // sum!(base,base).sum
    writeln(typeid(a+(b+c))); // sum!(base,sum!(base,base)).sum

    sum!(sum!(base,base),base) d;
    writeln(typeid(d));       // sum!(sum!(base,base),base).sum

    // the following produces
    //   Error: recursive template expansion for
    //   template argument sum!(base,base)
    writeln(typeid((a+b)+c)); // sum!(sum!(base,base),base).sum

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to