-
-
Notifications
You must be signed in to change notification settings - Fork 740
Open
Description
import std.algorithm : map;
import std.range : chain, front, iota, ElementType;
immutable string Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void main () {
// Range of string
auto str = iota(20).map!(v => Letters[v .. $]);
// Range of range of string
auto ror = iota(10).map!(v => str.save);
string[][] equiv = [ ["A", "B"], ["C", "D"] ];
pragma(msg, ElementType!(typeof(ror)), " -- ", ElementType!(typeof(equi\
v)));
pragma(msg, ElementType!(typeof(ror.front)), " -- ", ElementType!(typeo\
f(equiv.front)));
auto result = chain(ror, equiv);
}
Yields the error:
% ldc2 ror.d
MapResult!(__lambda_L8_C30, Result) -- string[]
string -- string
ror.d(14): Error: template `chain` is not callable using argument types `!()(MapResult!(__lambda_L10_C30, Result), string[][])`
auto result = chain(ror, equiv);
^
/home/mlang/dlang/ldc-1.41.0/bin/../import/std/range/package.d(977): Candidate is: `chain(Ranges...)(Ranges rs)`
with `Ranges = (MapResult!(__lambda_L10_C30, Result), string[][])`
must satisfy the following constraint:
` !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void)`
auto chain(Ranges...)(Ranges rs)
^
I expect it to work, since ror
is essentially a range of string, but the CommonType
check seems to be too restrictive for this.
Metadata
Metadata
Assignees
Labels
No labels