digitalmars.D.learn - recursive template expansion: Why does this not compile?
- Ontonator (5/19) Mar 20 2018 The aliases do not have to be aliases, as long as there is some
- Jonathan M Davis (11/39) Mar 20 2018 I'm not sure exactly what's happening, since I'm not very familiar with ...
- ag0aep6g (3/28) Mar 20 2018 Compiler bug. It works when you move the declaration of `B` before the
- Ontonator (2/15) Mar 21 2018 Is this a known bug, or should I report it?
- Jonathan M Davis (4/20) Mar 21 2018 If you can't find it searching on bugzilla, report it.
- Ontonator (3/24) Mar 22 2018 https://issues.dlang.org/show_bug.cgi?id=18646
The following code does not compile:void main() {} class SuperClass {} class TemplatedClass(T : SuperClass) {} class A : SuperClass { alias T = TemplatedClass!B; } class B : SuperClass { alias T = TemplatedClass!C; } class C : SuperClass {}It gives the error:test.d(12): Error: class `test.TemplatedClass(T : SuperClass)` recursive template expansion test.d(12): while looking for match for TemplatedClass!(C)The aliases do not have to be aliases, as long as there is some reference to the class (e.g. method and variable declarations also work). What exactly is the reason for this error?
Mar 20 2018
On Wednesday, March 21, 2018 00:47:18 Ontonator via Digitalmars-d-learn wrote:The following code does not compile:I'm not sure exactly what's happening, since I'm not very familiar with the exactly how template specializations are defined, but the problem clearly relates to the fact that you used a template specialization instead of a template constraint. If you change TemplatedClass to class TemplatedClass(T) if(is(T : SuperClass)) {} then the code compiles. - Jonathan M Davisvoid main() {} class SuperClass {} class TemplatedClass(T : SuperClass) {} class A : SuperClass { alias T = TemplatedClass!B; } class B : SuperClass { alias T = TemplatedClass!C; } class C : SuperClass {}It gives the error:test.d(12): Error: class `test.TemplatedClass(T : SuperClass)` recursive template expansion test.d(12): while looking for match for TemplatedClass!(C)The aliases do not have to be aliases, as long as there is some reference to the class (e.g. method and variable declarations also work). What exactly is the reason for this error?
Mar 20 2018
On 03/21/2018 01:47 AM, Ontonator wrote:The following code does not compile:Compiler bug. It works when you move the declaration of `B` before the one of `A`. Order shouldn't matter there.void main() {} class SuperClass {} class TemplatedClass(T : SuperClass) {} class A : SuperClass { alias T = TemplatedClass!B; } class B : SuperClass { alias T = TemplatedClass!C; } class C : SuperClass {}It gives the error:test.d(12): Error: class `test.TemplatedClass(T : SuperClass)` recursive template expansion test.d(12): while looking for match for TemplatedClass!(C)The aliases do not have to be aliases, as long as there is some reference to the class (e.g. method and variable declarations also work). What exactly is the reason for this error?
Mar 20 2018
On Wednesday, 21 March 2018 at 06:39:22 UTC, ag0aep6g wrote:On 03/21/2018 01:47 AM, Ontonator wrote:Is this a known bug, or should I report it?The following code does not compile:Compiler bug. It works when you move the declaration of `B` before the one of `A`. Order shouldn't matter there.[...]It gives the error:[...]The aliases do not have to be aliases, as long as there is some reference to the class (e.g. method and variable declarations also work). What exactly is the reason for this error?
Mar 21 2018
On Wednesday, March 21, 2018 22:50:32 Ontonator via Digitalmars-d-learn wrote:On Wednesday, 21 March 2018 at 06:39:22 UTC, ag0aep6g wrote:If you can't find it searching on bugzilla, report it. - Jonathan M DavisOn 03/21/2018 01:47 AM, Ontonator wrote:Is this a known bug, or should I report it?The following code does not compile:Compiler bug. It works when you move the declaration of `B` before the one of `A`. Order shouldn't matter there.[...]It gives the error:[...]The aliases do not have to be aliases, as long as there is some reference to the class (e.g. method and variable declarations also work). What exactly is the reason for this error?
Mar 21 2018
On Wednesday, 21 March 2018 at 23:05:22 UTC, Jonathan M Davis wrote:On Wednesday, March 21, 2018 22:50:32 Ontonator via Digitalmars-d-learn wrote:https://issues.dlang.org/show_bug.cgi?id=18646On Wednesday, 21 March 2018 at 06:39:22 UTC, ag0aep6g wrote:If you can't find it searching on bugzilla, report it. - Jonathan M DavisOn 03/21/2018 01:47 AM, Ontonator wrote:Is this a known bug, or should I report it?The following code does not compile:Compiler bug. It works when you move the declaration of `B` before the one of `A`. Order shouldn't matter there.[...]It gives the error:[...]The aliases do not have to be aliases, as long as there is some reference to the class (e.g. method and variable declarations also work). What exactly is the reason for this error?
Mar 22 2018