[Issue 8542] New: crosstalk between template instantiations
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 12 12:41:57 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8542
Summary: crosstalk between template instantiations
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: timon.gehr at gmx.ch
--- Comment #0 from timon.gehr at gmx.ch 2012-08-12 12:41:55 PDT ---
With DMD 2.060, the following code compiles and runs correctly with dmd
-version=A and dmd -version=B, but it fails to compile with
dmd -version=A -version=B
The code should compile and run correctly even when both version specifiers are
set.
import std.stdio, std.algorithm, std.range, std.bigint;
template Apply(alias a,T...){ alias a!T Apply; }
auto fun(T)(T n, T function(T) i, T function(T) d){
return
(z=>((T delegate(T,T) delegate(T delegate(T delegate(T,T),T,T)) AOY)
=>((m,e)=>reduce!((a,b)=>AOY((f,a,b)=>z(a)?b:i(f(d(a),
b)))(a,b))(zip([(T[] a)=>a.map!((T x)=>m(i(i(n)),x)).array,(T[]
a)=>a.map!((T x)=>m(i(i(i(n))),x)).array,delegate(T[] a)=>a.map!
(a=>a).array].map!(a=>&Apply!(map!a,T[][])),[[i(n),i(i(n)),i(i(i(n))),
i(i(i(i(n)))),i(i(i(i(i(n))))),i(i(i(i(i(i(n))))))],
[i(i(i(i(i(n))))),i(i(i(i(i(i(n)))))),i(i(i(i(i(i(i(n))))))),i(i(i(i(i(i(i(i(n)))))))),
i(i(i(i(i(i(i(i(i(n))))))))),i(i(i(i(n))))],[e(n,i(n)),e(i(n),i(i(n))),e(i(i(n)),i(n))]]
).map!(t=>t[0](t[1].map!(a=>[a,i(a),m(a,i(i(n)))]).array)).joiner.map!(a=>zip(a,retro(a))
.map!(t=>AOY((f,a,b)=>z(a)?b:i(f(d(a),b)))(t[0],t[1]))).joiner.chain(repeat(
i(i(i(i(i(i(i(i(i(i(i(i(n))))))))))))).map!(a=>AOY
((f,a,b)=>z(b)?a:f(d(a),d(b)))(a,i(i(i(i(i(i(i(i(i(i(i(i(i(n)))))))))))
)))).take(1))))((T a,T b)=>AOY((f,a,b)=>z(a)?n:AOY((g,a,b)=>z(a)?
b:i(g(d(a),b)))(b,f(d(a),b)))(a,b),AOY((h,a,b)=>z(a)?z(b)?i(n):n:z(b)?n:h(d(a),d(b)))))(
(a){struct S{ T delegate(T,T) delegate(S) r; } return
((x)=>x(S(x)))((S x)=>(T u,T v)=>a(x.r(x),u,v)); }))((T a)=>a==n);
}
void main(){
version(A) assert(fun(0,(int a)=>a+1,(int a)=>a-1)==1337);
static inc(int[] a){
if(!a.length) return [1];
if(a[0]<0) return a[0..$-1];
return a~(a[$-1]+1);
}
static dec(int[] a){
if(!a.length) return [-1];
if(a[0]>0) return a[0..$-1];
return a~(a[$-1]-1);
}
version(B) assert(fun((int[]).init,&inc,&dec).equal(iota(1,1338)));
}
--
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