570 – Bogus recursive mixin error

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 570 - Bogus recursive mixin error
Summary: Bogus recursive mixin error
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P2 major
Assignee: Walter Bright
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2006年11月18日 21:06 UTC by Michael Arntzenius
Modified: 2014年02月15日 13:22 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Michael Arntzenius 2006年11月18日 21:06:54 UTC
import std.stdio;
template TupleDecls(T, R ...) {
 T value;
 static if (R.length)
 mixin TupleDecls!(R) Inner;
}
struct TupleStruct(T ...) { mixin TupleDecls!(T); }
void main() {
 alias TupleStruct!(char[], char[]) twoStrings;
}
---------
The above code generates the following errors when compiling:
err.d(6): mixin err.TupleStruct!(char[],char[]).TupleStruct.TupleDecls!(char[],char[]).TupleDecls!(char[]) recursive mixin instantiation
err.d(12): template instance err.TupleStruct!(char[],char[]) error instantiating
The compiler seems to think that TupleDecls!(char[]) is the same as TupleDecls!(char[], char[]) somehow, and rejects instantiating the former inside the latter as being recursive, even though it's not.
Comment 1 Michael Arntzenius 2006年11月18日 21:09:42 UTC
Correction: it is recursive, but not infinitely recursive, as instantiating TupleDecls!(char[], char[]) inside of TupleDecls!(char[], char[]) would be. Also, the compiler accepts this code just fine when the types passed to the template aren't the same, as in TupleDecls!(char[], int).
Comment 2 Walter Bright 2008年07月09日 22:35:38 UTC
Fixed dmd 1.032 and 2.016


AltStyle によって変換されたページ (->オリジナル) /