Comment #0 by bearophile_hugs — 2011-10-22T18:07:35Z
A D2 program:
import std.stdio, std.typecons;
void main() {
Tuple!(const(char))[] a1;
Tuple!(immutable(char))[] a2;
writeln(a1, a2);
}
DMD 2.056head gives:
...\dmd2\src\phobos\std\format.d(1657): Error: static assert (isInputRange!(Tuple!(const(char))[])) is false
...\dmd2\src\phobos\std\format.d(2032): instantiated from here: formatValue!(LockingTextWriter,Tuple!(const(char))[],char)
...\dmd2\src\phobos\std\format.d(313): instantiated from here: formatGeneric!(LockingTextWriter,Tuple!(const(char))[],immutable(char))
...\dmd2\src\phobos\std\stdio.d(678): instantiated from here: formattedWrite!(LockingTextWriter,immutable(char),Tuple!(const(char))[])
...\dmd2\src\phobos\std\stdio.d(1511): instantiated from here: write!(Tuple!(const(char))[],Tuple!(immutable(char))[],char)
temp.d(5): instantiated from here: writeln!(Tuple!(const(char))[],Tuple!(immutable(char))[])
Comment #1 by k.hanazuki — 2011-10-26T11:41:54Z
This problem reduces to the following case,
where dmd rejects ref to struct type with a const field, with error:
std/array.d(460): Error: a[0u] isn't mutable
I think this is a compiler bug.
----
import std.array;
struct A {
const(char) c;
}
void main() {
A[] aa;
aa.front;
}
// ref T front(T)(T[] a)
// if (!isNarrowString!(T[]) && !is(T[] == void[]))
// {
// assert(a.length, "Attempting to fetch the front of an empty array of " ~
// typeof(a[0]).stringof);
// return a[0]; // ** std/array.d(460)
// }
Comment #2 by bearophile_hugs — 2011-10-26T15:12:53Z
(In reply to comment #1)
> I think this is a compiler bug.
Thank you for your reduction.
Then I have modified the 'component' of this bug report from Phobos to DMD.
Comment #3 by andrej.mitrovich — 2012-12-02T10:16:57Z
OP sample now works. If there is some other compiler problem please file a new bug (I don't see this error either "std/array.d(460): Error: a[0u] isn't mutable").
Comment #4 by k.hara.pg — 2012-12-02T19:03:31Z
The root cause is bug 6336, and was already fixed in 2.061head.