Consider the following program:

struct Expr(E) {
  const E expr;

// If I replace the return type with "auto", dmd enters into an infinite loop instead of failing (see below)
  @property Expr!(Transposed!E)  trans() {
    alias R = Transposed!E;
    return Expr!R(R(expr));
  }
}

struct Transposed(E) {
    const E expr;
}

struct Matrix {
  @property auto asExpression() {
    return Expr!(Matrix)(this);
  }

  alias asExpression this;
}

void main() {
    auto a = Matrix();
    auto e = a.trans;
    pragma(msg, typeof(e).stringof);
}

It fails to compile:

~> dmd -v | head -n1
DMD64 D Compiler v2.066-devel
~> dmd -c expression_template.d
expression_template.d(4): Error: template instance expression_template.Transposed!(Transposed!(Transposed!(Transposed!( .................. ) recursive expansion

Am I missing something?

Reply via email to