www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Weird "circular initialization of isInputRange" error

This piece of code (which I reduced with dustmite) gives me the 
following error when I try to compile it:

 $ rdmd -main parser.d parser.d(28): Error: circular 
 initialization of isInputRange
 parser.d(31): Error: template instance 
 std.meta.staticMap!(handler, ArrayReader*) error instantiating
 parser.d(36):        instantiated from here: 
 parser.d(40): Error: template instance 
 std.range.primitives.isInputRange!(ArrayReader*) error 
 /usr/include/dmd/phobos/std/meta.d(546):        instantiated 
 from here: F!(ArrayReader*)
 parser.d(43):        instantiated from here: staticMap!(toTD, 
 Failed: ["dmd", "-main", "-v", "-o-", "parser.d", "-I."]
I'm not really sure what's causing the error; I'm not declaring `isInputRange` in my code. Commenting out the definition of `TD` (the very last line) removes the error. Am I doing something wrong here, or is this a compiler bug? Tested with dmd v2.068.1 on Linux x64 Code: -----
 import std.range;
 import std.variant;
 import std.typetuple;
 template unpacker(Range)
 	/// Element data types. See `unpack` for usage.
 	alias MsgPackData = Algebraic!(
 	/// Reader range for arrays.
 	struct ArrayReader {
 		MsgPackData _front;
 		void update() {
 		void popFront() {
 	void drain(MsgPackData d) {
 		static handler(T)(T t) {
 			static if(isInputRange!T)
 		d.visit!(staticMap!(handler, MsgPackData.AllowedTypes));
 alias TestUnpacker = unpacker!(RefRange!(immutable(ubyte)[]));
 alias D = TestUnpacker.MsgPackData;
 template toTD(T) {
 	static if(isInputRange!T)
 		alias toTD = This;
 alias TD = Algebraic!(staticMap!(toTD, D.AllowedTypes)); // 
 test data type
Sep 16 2015