[Issue 8900] New: Using zip with char[] sometimes fails to compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 26 15:01:51 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8900
Summary: Using zip with char[] sometimes fails to compile
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: hsteoh at quickfur.ath.cx
--- Comment #0 from hsteoh at quickfur.ath.cx 2012-10-26 15:01:50 PDT ---
CODE:
-----------------------------
import std.algorithm;
import std.range;
version = Bug;
auto cartesianProd(R1,R2)(R1 range1, R2 range2)
{
version(Bug)
{
ElementType!R2 a;
return zip(range1.save, repeat(a));
}
else
{
// For some crazy reason, this one works.
ElementType!R1 a;
return zip(repeat(a), range2.save);
}
}
void main() {
auto arr = cartesianProd([1,2], ['a','b']);
}
------------------------------
DMD output:
------------------------------
/usr/src/d/phobos/std/format.d(1937): Error: template std.range.walkLength does
not match any function template declaration
/usr/src/d/phobos/std/range.d(1321): Error: template std.range.walkLength
cannot deduce template function from argument types !()(Repeat!(dchar))
/usr/src/d/phobos/std/format.d(2495): Error: template instance
std.format.formatRange!(Appender!(string),Repeat!(dchar),char) error
instantiating
/usr/src/d/phobos/std/format.d(2172): instantiated from here:
formatValue!(Appender!(string),Repeat!(dchar),char)
/usr/src/d/phobos/std/typecons.d(552): instantiated from here:
formatElement!(Appender!(string),Repeat!(dchar),char)
/usr/src/d/phobos/std/range.d(3700): instantiated from here:
Tuple!(int[],Repeat!(dchar))
/usr/src/d/phobos/std/range.d(4060): ... (1 instantiations, -v to show)
...
test.d(11): instantiated from here: zip!(int[],Repeat!(dchar))
test.d(22): instantiated from here: cartesianProd!(int[],char[])
/usr/src/d/phobos/std/format.d(2172): Error: template instance
std.format.formatValue!(Appender!(string),Repeat!(dchar),char) error
instantiating
/usr/src/d/phobos/std/typecons.d(552): instantiated from here:
formatElement!(Appender!(string),Repeat!(dchar),char)
/usr/src/d/phobos/std/range.d(3700): instantiated from here:
Tuple!(int[],Repeat!(dchar))
/usr/src/d/phobos/std/range.d(4060): instantiated from here:
Zip!(int[],Repeat!(dchar))
test.d(11): instantiated from here: zip!(int[],Repeat!(dchar))
test.d(22): instantiated from here: cartesianProd!(int[],char[])
/usr/src/d/phobos/std/typecons.d(552): Error: template instance
std.format.formatElement!(Appender!(string),Repeat!(dchar),char) error
instantiating
/usr/src/d/phobos/std/range.d(3700): instantiated from here:
Tuple!(int[],Repeat!(dchar))
/usr/src/d/phobos/std/range.d(4060): instantiated from here:
Zip!(int[],Repeat!(dchar))
test.d(11): instantiated from here: zip!(int[],Repeat!(dchar))
test.d(22): instantiated from here: cartesianProd!(int[],char[])
/usr/src/d/phobos/std/range.d(4060): Error: template instance
std.range.Zip!(int[],Repeat!(dchar)) error instantiating
test.d(11): instantiated from here: zip!(int[],Repeat!(dchar))
test.d(22): instantiated from here: cartesianProd!(int[],char[])
test.d(11): Error: template instance std.range.zip!(int[],Repeat!(dchar)) error
instantiating
test.d(22): instantiated from here: cartesianProd!(int[],char[])
test.d(22): Error: template instance test.cartesianProd!(int[],char[]) error
instantiating
------------------------------
Oddly enough, commenting out the "version = Bug" line at the top (which
switches the order of a few parameters to zip) makes the problem go away.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list