[Issue 3869] New: Unreasonable error without line number: "recursive template expansion"
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 2 02:41:05 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3869
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
AssignedTo: nobody at puremagic.com
ReportedBy: Norbert at Nemec-online.de
--- Comment #0 from Norbert Nemec <Norbert at Nemec-online.de> 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list