Weird "circular initialization of isInputRange" error
Alex Parrill via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 16 07:37:28 PDT 2015
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:
> unpacker!(RefRange!(immutable(ubyte)[]))
> parser.d(40): Error: template instance
> std.range.primitives.isInputRange!(ArrayReader*) error
> instantiating
> /usr/include/dmd/phobos/std/meta.d(546): instantiated
> from here: F!(ArrayReader*)
> parser.d(43): instantiated from here: staticMap!(toTD,
> ArrayReader*)
> 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!(
> ArrayReader*,
> );
>
>
> /// Reader range for arrays.
> struct ArrayReader {
> MsgPackData _front;
> void update() {
> _front.drain;
> }
>
> void popFront() {
> update;
> }
> }
>
> void drain(MsgPackData d) {
> static handler(T)(T t) {
> static if(isInputRange!T)
> data;
> }
> 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
More information about the Digitalmars-d
mailing list