Weird template error in Phobos (after editing) that I can't quite get. Compiler bug?
Atila Neves via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 22 07:06:56 PDT 2017
isInputRange looks like this:
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {} // can test for empty
r.popFront; // can invoke popFront()
auto h = r.front; // can get the front of the range
}));
}
If I change the `enum bool` line to `enum bool isInputRange =
true && is(typeof(`, all is fine.
If instead I:
enum foo = true;
enum bool isInputRange = foo && is(typeof(
Then:
std/range/primitives.d(352): Error: static assert "Cannot put a
char[] into a Appender!string."
std/format.d(1877): instantiated from here:
put!(Appender!string, char[])
std/format.d(1784): instantiated from here:
formatUnsigned!(Appender!string, ulong, char)
std/format.d(1755): instantiated from here:
formatIntegral!(Appender!string, ulong, char)
std/format.d(3778): ... (3 instantiations, -v to show) ...
std/typecons.d(421): instantiated from here: format!(char,
ulong, ulong)
std/encoding.d(3468): instantiated from here: Tuple!(BOM,
"schema", ubyte[], "sequence")
Surely they should be identical? Obviously I was trying to do
something else with an enum, but this is the reduced sample.
Atila
More information about the Digitalmars-d-learn
mailing list