- Notifications
You must be signed in to change notification settings - Fork 36
Closed
Labels
Description
I have one function that applies map and then another function calls that function and adds another map to it. I get an error about nesting pipe calls or something. If I manually use pipe or combine the functions, then there is no error.
auto foo(T)(T x) { import mir.ndslice.topology : map; return x.map!(a => a + 1); } auto bar(T)(T x) { import mir.ndslice.topology : map; return x.foo.map!(a => a + 2); } void main() { import mir.ndslice.topology : iota, map; import mir.functional : pipe; import std.stdio : writeln; auto data = iota(5); auto result = iota([5], 3); auto x = data.map!(a => a + 1).map!(a => a + 2); //piping them normally works correctly assert(x == result); auto y = data.bar; //error here //assert(y == result); auto z = data.pipe!(foo, a => a + 2); //this works too assert(z == result); }
Error (note: using 0.7.0-alpha8):
C:\ProgrammingFiles\DFiles\testing\testing_mir_algorithm>dub run Performing "debug" build using dmd for x86. mir-algorithm 0.7.0: target for configuration "library" is up to date. testing_mir_algorithm 0.0.1: building configuration "application"... ..\..\dubFolder\mir-algorithm-0.7.0-alpha8\source\mir\ndslice\iterator.d(621,71) : Error: template instance pipe!(__lambda2, __lambda2) pipe!(__lambda2, __lambda 2) is nested in both foo and bar ..\..\dubFolder\mir-algorithm-0.7.0-alpha8\source\mir\ndslice\iterator.d(633,24) : Error: template instance app.bar!(Slice!(cast(SliceKind)2, [1u], IotaIterator! int)).bar.__map!(__lambda2) error instantiating ..\..\dubFolder\mir-algorithm-0.7.0-alpha8\source\mir\ndslice\topology.d(2262,52 ): instantiated from here: mapIterator!(__lambda2, MapIterator!(IotaItera tor!int, __lambda2)) source\app.d(12,17): instantiated from here: map!(cast(SliceKind)2, [1u], MapIterator!(IotaIterator!int, __lambda2)) source\app.d(27,18): instantiated from here: bar!(Slice!(cast(SliceKind)2 , [1u], IotaIterator!int)) dmd failed with exit code 1.