1 /*
2 REQUIRED_ARGS: -preview=rvaluerefparam
3 PERMUTE_ARGS:
4 TEST_OUTPUT:
5 ---
6 func
7 double
8 All good 1
9 All good 2
10 All good 3
11 _D7imports10testmangle12detectMangleFPSQBlQBg6DetectZQq
12 _D7imports10testmangle__T10DetectTmplTiZQpFNaNbNiNfZv
13 true
14 false
15 uint
16 int[]
17 int[]
18 const(K5886)
19 4 ; const(K5886)
20 8 ; const(K5886)
21 K5886
22 immutable(K5886)
23 4 ; K5886
24 4 ; immutable(K5886)
25 1 ; K5886
26 2 ; const(K5886)
27 3 ; immutable(K5886)
28 8 ; K5886
29 9 ; const(K5886)
30 10 ; immutable(K5886)
31 > U = int, N:$?:64=ulong = 3LU|32=uint = 3u$
32 K=string, V=int
33 K=char, V=string
34 T = SA, E = int, dim = $?:64=5LU|32=5u$
35 T = DA, E = int
36 T = AA, K = string, V = int
37 pure nothrow @nogc @safe void(int t)
38 pure nothrow @nogc @safe void(int t)
39 T = byte
40 T = char
41 ---
42 
43 RUN_OUTPUT:
44 ---
45 typeof(T)=double typeof(S)=int
46 typeof(T)=double typeof(S)=int
47 typeof(T)=float typeof(S)=int
48 Success
49 ---
50 */
51 
52 module breaker;
53 
54 import core.stdc.stdio, core.vararg;
55 
56 /**********************************/
57 
58 U foo(T, U)(U i)
59 {
60     return i + 1;
61 }
62 
63 int foo(T)(int i)
64 {
65     return i + 2;
66 }
67 
68 void test1()
69 {
70     auto i = foo!(int)(2L);
71 //    assert(i == 4);    // now returns 3
72 }
73 
74 /**********************************/
75 
76 U foo2(T, U)(U i)
77 {
78     return i + 1;
79 }
80 
81 void test2()
82 {
83     auto i = foo2!(int)(2L);
84     assert(i == 3);
85 }
86 
87 /**********************************/
88 
89 class Foo3
90 {
91     T bar(T,U)(U u)
92     {
93         return cast(T)u;
94     }
95 }
96 
97 void test3()
98 {
99   Foo3 foo = new Foo3;
100   int i = foo.bar!(int)(1.0);
101   assert(i == 1);
102 }
103 
104 
105 /**********************************/
106 
107 T* begin4(T)(T[] a) { return a.ptr; }
108 
109 void copy4(string pred = "", Ranges...)(Ranges rs)
110 {
111     alias rs[$ - 1] target;
112     pragma(msg, typeof(target).stringof);
113     auto tb = begin4(target);//, te = end(target);
114 }
115 
116 void test4()
117 {
118     int[] a, b, c;
119     copy4(a, b, c);
120     // comment the following line to prevent compiler from crashing
121     copy4!("a > 1")(a, b, c);
122 }
123 
124 /**********************************/
125 
126 template foo5(T,S)
127 {
128     void foo5(T t, S s) {
129         const tstr = typeid(T).toString();
130         const sstr = typeid(S).toString();
131         printf("typeof(T)=%.*s typeof(S)=%.*s\n",
132                cast(int)tstr.length, tstr.ptr, cast(int)sstr.length, sstr.ptr);
133     }
134 }
135 
136 template bar5(T,S)
137 {
138     void bar5(S s) {
139         const tstr = typeid(T).toString();
140         const sstr = typeid(S).toString();
141         printf("typeof(T)=%.*s typeof(S)=%.*s\n",
142                cast(int)tstr.length, tstr.ptr, cast(int)sstr.length, sstr.ptr);
143     }
144 }
145 
146 
147 void test5()
148 {
149     foo5(1.0,33);
150     bar5!(double,int)(33);
151     bar5!(float)(33);
152 }
153 
154 /**********************************/
155 
156 int foo6(T...)(auto ref T x)
157 {   int result;
158 
159     foreach (i, v; x)
160     {
161         if (v == 10)
162             assert(__traits(isRef, x[i]));
163         else
164             assert(!__traits(isRef, x[i]));
165         result += v;
166     }
167     return result;
168 }
169 
170 void test6()
171 {   int y = 10;
172     int r;
173     r = foo6(8);
174     assert(r == 8);
175     r = foo6(y);
176     assert(r == 10);
177     r = foo6(3, 4, y);
178     assert(r == 17);
179     r = foo6(4, 5, y);
180     assert(r == 19);
181     r = foo6(y, 6, y);
182     assert(r == 26);
183 }
184 
185 /**********************************/
186 
187 auto ref min(T, U)(auto ref T lhs, auto ref U rhs)
188 {
189     return lhs > rhs ? rhs : lhs;
190 }
191 
192 void test7()
193 {   int x = 7, y = 8;
194     int i;
195 
196     i = min(4, 3);
197     assert(i == 3);
198     i = min(x, y);
199     assert(i == 7);
200     min(x, y) = 10;
201     assert(x == 10);
202     static assert(!__traits(compiles, min(3, y) = 10));
203     static assert(!__traits(compiles, min(y, 3) = 10));
204 }
205 
206 /**********************************/
207 // https://issues.dlang.org/show_bug.cgi?id=5946
208 
209 template TTest8()
210 {
211     int call(){ return this.g(); }
212 }
213 class CTest8
214 {
215     int f() { mixin TTest8!(); return call(); }
216     int g() { return 10; }
217 }
218 void test8()
219 {
220     assert((new CTest8()).f() == 10);
221 }
222 
223 /**********************************/
224 // https://issues.dlang.org/show_bug.cgi?id=693
225 
226 template TTest9(alias sym)
227 {
228     int call(){ return sym.g(); }
229 }
230 class CTest9
231 {
232     int f1() { mixin TTest9!(this); return call(); }
233     int f2() { mixin TTest9!this; return call(); }
234     int g() { return 10; }
235 }
236 void test9()
237 {
238     assert((new CTest9()).f1() == 10);
239     assert((new CTest9()).f2() == 10);
240 }
241 
242 /**********************************/
243 // https://issues.dlang.org/show_bug.cgi?id=1780
244 
245 template Tuple1780(Ts ...) { alias Ts Tuple1780; }
246 
247 template Decode1780( T )                            { alias Tuple1780!() Types; }
248 template Decode1780( T : TT!(Us), alias TT, Us... ) { alias Us Types; }
249 
250 void test1780()
251 {
252     struct S1780(T1, T2) {}
253 
254     // should extract tuple (bool,short) but matches the first specialisation
255     alias Decode1780!( S1780!(bool,short) ).Types SQ1780;  // --> SQ2 is empty tuple!
256     static assert(is(SQ1780 == Tuple1780!(bool, short)));
257 }
258 
259 /**********************************/
260 // https://issues.dlang.org/show_bug.cgi?id=1659
261 
262 class Foo1659 { }
263 class Bar1659 : Foo1659 { }
264 
265 void f1659(T : Foo1659)() { }
266 void f1659(alias T)() { static assert(false); }
267 
268 void test1659()
269 {
270     f1659!Bar1659();
271 }
272 
273 /**********************************/
274 // https://issues.dlang.org/show_bug.cgi?id=2025
275 
276 struct S2025 {}
277 void f2025() {}
278 
279 template Foo2025(int i) { enum Foo2025 = 1; }
280 template Foo2025(TL...) { enum Foo2025 = 2; }
281 static assert(Foo2025!1 == 1);
282 static assert(Foo2025!int == 2);
283 static assert(Foo2025!S2025 == 2);
284 static assert(Foo2025!f2025 == 2);
285 
286 template Bar2025(T)    { enum Bar2025 = 1; }
287 template Bar2025(A...) { enum Bar2025 = 2; }
288 static assert(Bar2025!1 == 2);
289 static assert(Bar2025!int == 1);    // 2 -> 1
290 static assert(Bar2025!S2025 == 1);  // 2 -> 1
291 static assert(Bar2025!f2025 == 2);
292 
293 template Baz2025(T)       { enum Baz2025 = 1; }
294 template Baz2025(alias A) { enum Baz2025 = 2; }
295 static assert(Baz2025!1 == 2);
296 static assert(Baz2025!int == 1);
297 static assert(Baz2025!S2025 == 1);  // 2 -> 1
298 static assert(Baz2025!f2025 == 2);
299 
300 /**********************************/
301 // https://issues.dlang.org/show_bug.cgi?id=3608
302 
303 template foo3608(T, U){}
304 
305 template BaseTemplate3608(alias TTT : U!V, alias U, V...)
306 {
307     alias U BaseTemplate3608;
308 }
309 template TemplateParams3608(alias T : U!V, alias U, V...)
310 {
311     alias V TemplateParams3608;
312 }
313 
314 template TyueTuple3608(T...) { alias T TyueTuple3608; }
315 
316 void test3608()
317 {
318     alias foo3608!(int, long) Foo3608;
319 
320     static assert(__traits(isSame, BaseTemplate3608!Foo3608, foo3608));
321     static assert(is(TemplateParams3608!Foo3608 == TyueTuple3608!(int, long)));
322 }
323 
324 /**********************************/
325 // https://issues.dlang.org/show_bug.cgi?id=5015
326 
327 import breaker;
328 
329 static if (is(ElemType!(int))){}
330 
331 template ElemType(T) {
332   alias _ElemType!(T).type ElemType;
333 }
334 
335 template _ElemType(T) {
336     alias r type;
337 }
338 
339 /**********************************/
340 // https://issues.dlang.org/show_bug.cgi?id=5185
341 
342 class C5185(V)
343 {
344     void f()
345     {
346         C5185!(C5185!(int)) c;
347     }
348 }
349 
350 void test5185()
351 {
352     C5185!(C5185!(int)) c;
353 }
354 
355 /**********************************/
356 // https://issues.dlang.org/show_bug.cgi?id=5893
357 
358 class C5893
359 {
360     int concatAssign(C5893 other) { return 1; }
361     int concatAssign(int other) { return 2; } // to demonstrate overloading
362 
363     template opOpAssign(string op) if (op == "~")
364     { alias concatAssign opOpAssign; }
365 
366     int opOpAssign(string op)(int other) if (op == "+") { return 3; }
367 }
368 
369 void test5893()
370 {
371     auto c = new C5893;
372     assert(c.opOpAssign!"~"(c) == 1); // works
373     assert(c.opOpAssign!"~"(1) == 2); // works
374     assert((c ~= 1) == 2);
375     assert((c += 1) == 3);  // overload
376 }
377 
378 /**********************************/
379 // https://issues.dlang.org/show_bug.cgi?id=5988
380 
381 template Templ5988(alias T)
382 {
383     alias T!int Templ5988;
384 }
385 
386 class C5988a(T) { Templ5988!C5988a foo; }
387 //Templ5988!C5988a foo5988a;    // Commented version
388 void test5988a() { C5988a!int a; }  // Was error, now works
389 
390 class C5988b(T) { Templ5988!C5988b foo; }
391 Templ5988!C5988b foo5988b;      // Uncomment version
392 void test5988b() { C5988b!int a; }  // Works
393 
394 /**********************************/
395 // https://issues.dlang.org/show_bug.cgi?id=6404
396 
397 // receive only rvalue
398 void rvalue(T)(auto ref T x) if (!__traits(isRef, x)) {}
399 void rvalueVargs(T...)(auto ref T x) if (!__traits(isRef, x[0])) {}
400 
401 // receive only lvalue
402 void lvalue(T)(auto ref T x) if ( __traits(isRef, x)) {}
403 void lvalueVargs(T...)(auto ref T x) if ( __traits(isRef, x[0])) {}
404 
405 void test6404()
406 {
407     int n;
408 
409     static assert(!__traits(compiles, rvalue(n)));
410     static assert( __traits(compiles, rvalue(0)));
411 
412     static assert( __traits(compiles, lvalue(n)));
413     static assert(!__traits(compiles, lvalue(0)));
414 
415     static assert(!__traits(compiles, rvalueVargs(n)));
416     static assert( __traits(compiles, rvalueVargs(0)));
417 
418     static assert( __traits(compiles, lvalueVargs(n)));
419     static assert(!__traits(compiles, lvalueVargs(0)));
420 }
421 
422 /**********************************/
423 // https://issues.dlang.org/show_bug.cgi?id=2246
424 
425 class A2246(T,d){
426     T p;
427 }
428 
429 class B2246(int rk){
430     int[rk] p;
431 }
432 
433 class C2246(T,int rk){
434     T[rk] p;
435 }
436 
437 template f2246(T:A2246!(U,d),U,d){
438     void f2246(){ }
439 }
440 
441 template f2246(T:B2246!(rank),int rank){
442     void f2246(){ }
443 }
444 
445 template f2246(T:C2246!(U,rank),U,int rank){
446     void f2246(){ }
447 }
448 
449 void test2246(){
450     A2246!(int,long) a;
451     B2246!(2) b;
452     C2246!(int,2) c;
453     f2246!(A2246!(int,long))();
454     f2246!(B2246!(2))();
455     f2246!(C2246!(int,2))();
456 }
457 
458 /**********************************/
459 // https://issues.dlang.org/show_bug.cgi?id=2296
460 
461 void foo2296(size_t D)(int[D] i...){}
462 void test2296()
463 {
464     foo2296(1, 2, 3);
465 }
466 
467 /**********************************/
468 // https://issues.dlang.org/show_bug.cgi?id=1684
469 
470 template Test1684( uint memberOffset ){}
471 
472 class MyClass1684 {
473     int flags2;
474     mixin Test1684!(cast(uint)flags2.offsetof) t1; // compiles ok
475     mixin Test1684!(cast(int)flags2.offsetof)  t2; // compiles ok
476     mixin Test1684!(flags2.offsetof)           t3; // Error: no property 'offsetof' for type 'int'
477 }
478 
479 /**********************************/
480 
481 void bug4984a(int n)() if (n > 0 && is(typeof(bug4984a!(n-1) ()))) {
482 }
483 
484 void bug4984a(int n : 0)() {
485 }
486 
487 void bug4984b(U...)(U args) if ( is(typeof( bug4984b(args[1..$]) )) ) {
488 }
489 
490 void bug4984b(U)(U u) {
491 }
492 
493 void bug4984() {
494   // Note: compiling this overflows the stack if dmd is build with DEBUG
495   //bug4984a!400();
496     bug4984a!200();
497     bug4984b(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19);
498 }
499 
500 /***************************************/
501 // https://issues.dlang.org/show_bug.cgi?id=2579
502 
503 void foo2579(T)(T delegate(in Object) dlg)
504 {
505 }
506 
507 void test2579()
508 {
509     foo2579( (in Object o) { return 15; } );
510 }
511 
512 /**********************************/
513 // https://issues.dlang.org/show_bug.cgi?id=2803
514 
515 auto foo2803(T)(T t = 0) { return t; }
516 
517 struct S2803 {}
518 S2803 s2803;
519 ref S2803 getS2803() { return s2803; }
520 auto fun2803(T, U)(T t, ref U u = getS2803)
521 {
522     static assert(is(U == S2803));
523     return &u;
524 }
525 
526 // from the past version of std.conv
527 template to2803(T) { T to2803(S)(S src) { return T.init; } }
528 auto toImpl2803a(T, S)(S s, in T left, in T sep = ", ", in T right = "]") {}
529 auto toImpl2803b(T, S)(S s, in T left = to2803!T(S.stringof~"("), in T right = ")") {}
530 auto toImpl2803c(T, S)(S s, in T left =          S.stringof~"(" , in T right = ")") {}  // combination with enh 13944
531 
532 // from std.range.package in 2.067a.
533 auto enumerate2803(En = size_t, R)(R r, En start = 0)
534 {
535     // The type of 'start' should be size_t, it's the defaultArg of En,
536     // rather than the deduced type from its defualtArg '0'.
537     static assert(is(typeof(start) == size_t));
538     return start;
539 }
540 
541 // from std.numeric.
542 alias ElementType2803(R) = typeof(R.init[0].init);
543 void normalize2803(R)(R range, ElementType2803!R sum = 1)
544 {
545     // The type of 'sum' should be determined to ElementType!(double[]) == double
546     // before the type deduction from its defaultArg '1'.
547     static assert(is(typeof(sum) == double));
548 }
549 
550 auto foo14468(T)(T[]...) { return 1; }
551 auto foo14468(bool flag, T)(T[]...) { return 2; }
552 
553 void test2803()
554 {
555     assert(foo2803() == 0);
556     assert(foo2803(1) == 1);
557 
558     S2803 s;
559     assert(fun2803(1)    is &s2803);
560     assert(fun2803(1, s) is &s);
561 
562     // regression cases
563 
564     toImpl2803a!string(1, "[");
565 
566     toImpl2803b! string(1);
567     toImpl2803b!wstring(1);
568     toImpl2803b!dstring(1);
569 
570     toImpl2803c! string(1);
571     toImpl2803c!wstring(1); // requires enhancement 13944
572     toImpl2803c!dstring(1); // requires enhancement 13944
573 
574     enumerate2803([1]);
575 
576     double[] a = [];
577     normalize2803(a);
578 
579     assert(foo14468!int() == 1);
580 }
581 
582 /**********************************/
583 // https://issues.dlang.org/show_bug.cgi?id=6613
584 
585 alias Tuple6613(T...) = T;
586 
587 void f6613(T...)(int x = 0, T xs = Tuple6613!())
588 {
589     assert(x == 0);
590     static assert(T.length == 0);
591 }
592 
593 void test6613()
594 {
595     f6613();
596 }
597 
598 /**********************************/
599 // https://issues.dlang.org/show_bug.cgi?id=4953
600 
601 void bug4953(T = void)(short x) {}
602 static assert(is(typeof(bug4953(3))));
603 
604 /**********************************/
605 // https://issues.dlang.org/show_bug.cgi?id=5886
606 // https://issues.dlang.org/show_bug.cgi?id=5393
607 
608 mixin template Foo5886(T)
609 {
610     void foo(U : T, this X)() const { static assert(is(X == const K5886)); }
611 }
612 
613 struct K5886
614 {
615     void get1(this T)() const
616     {
617         pragma(msg, T);
618     }
619     void get2(int N=4, this T)() const
620     {
621         pragma(msg, N, " ; ", T);
622     }
623 
624     mixin Foo5886!double;
625     mixin Foo5886!string;
626 
627     void test() const
628     {
629         get1;       // OK
630         get2;       // OK
631         get2!8;     // NG
632 
633         foo!(int);
634         foo!(typeof(null));
635     }
636 }
637 
638 void test5886()
639 {
640     K5886 km;
641     const(K5886) kc;
642     immutable(K5886) ki;
643 
644     km.get1;        // OK
645     kc.get1;        // OK
646     ki.get1;        // OK
647     km.get2;        // OK
648     kc.get2;        // OK
649     ki.get2;        // OK
650     km.get2!(1, K5886);             // Ugly
651     kc.get2!(2, const(K5886));      // Ugly
652     ki.get2!(3, immutable(K5886));  // Ugly
653     km.get2!8;      // Error
654     kc.get2!9;      // Error
655     ki.get2!10;     // Error
656 }
657 
658 // --------
659 
660 void test5393()
661 {
662     class A
663     {
664         void opDispatch (string name, this T) () { }
665     }
666 
667     class B : A {}
668 
669     auto b = new B;
670     b.foobar();
671 }
672 
673 /**********************************/
674 // https://issues.dlang.org/show_bug.cgi?id=5896
675 
676 struct X5896
677 {
678                  T opCast(T)(){ return 1; }
679            const T opCast(T)(){ return 2; }
680        immutable T opCast(T)(){ return 3; }
681           shared T opCast(T)(){ return 4; }
682     const shared T opCast(T)(){ return 5; }
683 }
684 void test5896()
685 {
686     auto xm =              X5896  ();
687     auto xc =        const(X5896) ();
688     auto xi =    immutable(X5896) ();
689     auto xs =       shared(X5896) ();
690     auto xcs= const(shared(X5896))();
691     assert(cast(int)xm == 1);
692     assert(cast(int)xc == 2);
693     assert(cast(int)xi == 3);
694     assert(cast(int)xs == 4);
695     assert(cast(int)xcs== 5);
696 }
697 
698 /**********************************/
699 // https://issues.dlang.org/show_bug.cgi?id=6312
700 
701 void h6312() {}
702 
703 class Bla6312
704 {
705     mixin wrap6312!h6312;
706 }
707 
708 mixin template wrap6312(alias f)
709 {
710     void blub(alias g = f)()
711     {
712         g();
713     }
714 }
715 
716 void test6312()
717 {
718     Bla6312 b = new Bla6312();
719     b.blub();
720 }
721 
722 /**********************************/
723 // https://issues.dlang.org/show_bug.cgi?id=6825
724 
725 void test6825()
726 {
727     struct File
728     {
729         void write(S...)(S args) {}
730     }
731 
732     void dump(void delegate(string) d) {}
733 
734     auto o = File();
735     dump(&o.write!string);
736 }
737 
738 /**********************************/
739 // https://issues.dlang.org/show_bug.cgi?id=6789
740 
741 template isStaticArray6789(T)
742 {
743     static if (is(T U : U[N], size_t N))    // doesn't match
744     {
745         pragma(msg, "> U = ", U, ", N:", typeof(N), " = ", N);
746         enum isStaticArray6789 = true;
747     }
748     else
749         enum isStaticArray6789 = false;
750 }
751 
752 void test6789()
753 {
754     alias int[3] T;
755     static assert(isStaticArray6789!T);
756 }
757 
758 /**********************************/
759 // https://issues.dlang.org/show_bug.cgi?id=2778
760 
761 struct ArrayWrapper2778(T)
762 {
763     T[] data;
764     alias data this;
765 }
766 
767 void doStuffFunc2778(int[] data) {}
768 
769 void doStuffTempl2778(T)(T[] data) {}
770 
771 int doStuffTemplOver2778(T)(void* data) { return 1; }
772 int doStuffTemplOver2778(T)(ArrayWrapper2778!T w) { return 2; }
773 
774 void test2778()
775 {
776     ArrayWrapper2778!(int) foo;
777 
778     doStuffFunc2778(foo);  // Works.
779 
780     doStuffTempl2778!(int)(foo);  // Works.
781 
782     doStuffTempl2778(foo);  // Error
783 
784     assert(doStuffTemplOver2778(foo) == 2);
785 }
786 
787 // ----
788 
789 void test2778aa()
790 {
791     void foo(K, V)(V[K] aa){ pragma(msg, "K=", K, ", V=", V); }
792 
793     int[string] aa1;
794     foo(aa1);   // OK
795 
796     struct SubTypeOf(T)
797     {
798         T val;
799         alias val this;
800     }
801     SubTypeOf!(string[char]) aa2;
802     foo(aa2);   // NG
803 }
804 
805 // ----
806 
807 void test2778get()
808 {
809     void foo(ubyte[]){}
810 
811     static struct S
812     {
813         ubyte[] val = [1,2,3];
814         @property ref ubyte[] get() return { return val; }
815         alias get this;
816     }
817     S s;
818     foo(s);
819 }
820 
821 /**********************************/
822 // https://issues.dlang.org/show_bug.cgi?id=6208
823 
824 int getRefNonref(T)(ref T s){ return 1; }
825 int getRefNonref(T)(    T s){ return 2; }
826 
827 int getAutoRef(T)(auto ref T s){ return __traits(isRef, s) ? 1 : 2; }
828 
829 void getOut(T)(out T s){ {} }
830 
831 void getLazy1(T=int)(lazy void s){ s(), s(); }
832 void getLazy2(T)(lazy T s){  s(), s(); }
833 
834 void test6208a()
835 {
836     int lvalue;
837     int rvalue(){ int t; return t; }
838 
839     assert(getRefNonref(lvalue  ) == 1);
840     assert(getRefNonref(rvalue()) == 2);
841 
842     assert(getAutoRef(lvalue  ) == 1);
843     assert(getAutoRef(rvalue()) == 2);
844 
845     static assert( __traits(compiles, getOut(lvalue  )));
846     static assert(!__traits(compiles, getOut(rvalue())));
847 
848     int n1; getLazy1(++n1); assert(n1 == 2);
849     int n2; getLazy2(++n2); assert(n2 == 2);
850 
851     struct X
852     {
853         int f(T)(auto ref T t){ return 1; }
854         int f(T)(auto ref T t, ...){ return -1; }
855     }
856     auto xm =       X ();
857     auto xc = const(X)();
858     int n;
859     assert(xm.f!int(n) == 1);   // resolved 'auto ref'
860     assert(xm.f!int(0) == 1);   // ditto
861 }
862 
863 void test6208b()
864 {
865     void foo(T)(const T value) if (!is(T == int)) {}
866 
867     int mn;
868     const int cn;
869     static assert(!__traits(compiles, foo(mn)));    // OK -> OK
870     static assert(!__traits(compiles, foo(cn)));    // NG -> OK
871 }
872 
873 void test6208c()
874 {
875     struct S
876     {
877         // Original test case.
878         int foo(V)(in V v)                         { return 1; }
879         int foo(Args...)(auto ref const Args args) { return 2; }
880 
881         // Reduced test cases
882 
883         int hoo(V)(const V v)             { return 1; }  // typeof(10) : const V       -> MATCHconst
884         int hoo(Args...)(const Args args) { return 2; }  // typeof(10) : const Args[0] -> MATCHconst
885         // If deduction matching level is same, tuple parameter is less specialized than others.
886 
887         int bar(V)(V v)                   { return 1; }  // typeof(10) : V             -> MATCHexact
888         int bar(Args...)(const Args args) { return 2; }  // typeof(10) : const Args[0] -> MATCHconst
889 
890         int baz(V)(const V v)             { return 1; }  // typeof(10) : const V -> MATCHconst
891         int baz(Args...)(Args args)       { return 2; }  // typeof(10) : Args[0] -> MATCHexact
892 
893         inout(int) war(V)(inout V v)            { return 1; }
894         inout(int) war(Args...)(inout Args args){ return 2; }
895 
896         inout(int) waz(Args...)(inout Args args){ return 0; }   // wild deduction test
897     }
898 
899     S s;
900 
901     int nm = 10;
902     assert(s.foo(nm) == 1);
903     assert(s.hoo(nm) == 1);
904     assert(s.bar(nm) == 1);
905     assert(s.baz(nm) == 2);
906     assert(s.war(nm) == 1);
907     static assert(is(typeof(s.waz(nm)) == int));
908 
909     const int nc = 10;
910     assert(s.foo(nc) == 1);
911     assert(s.hoo(nc) == 1);
912     assert(s.bar(nc) == 1);
913     assert(s.baz(nc) == 1);
914     assert(s.war(nc) == 1);
915     static assert(is(typeof(s.waz(nc)) == const(int)));
916 
917     immutable int ni = 10;
918     assert(s.foo(ni) == 1);
919     assert(s.hoo(ni) == 1);
920     assert(s.bar(ni) == 1);
921     assert(s.baz(ni) == 2);
922     assert(s.war(ni) == 1);
923     static assert(is(typeof(s.waz(ni)) == immutable(int)));
924 
925     static assert(is(typeof(s.waz(nm, nm)) == int));
926     static assert(is(typeof(s.waz(nm, nc)) == const(int)));
927     static assert(is(typeof(s.waz(nm, ni)) == const(int)));
928     static assert(is(typeof(s.waz(nc, nm)) == const(int)));
929     static assert(is(typeof(s.waz(nc, nc)) == const(int)));
930     static assert(is(typeof(s.waz(nc, ni)) == const(int)));
931     static assert(is(typeof(s.waz(ni, nm)) == const(int)));
932     static assert(is(typeof(s.waz(ni, nc)) == const(int)));
933     static assert(is(typeof(s.waz(ni, ni)) == immutable(int)));
934 }
935 
936 /**********************************/
937 // https://issues.dlang.org/show_bug.cgi?id=6805
938 
939 struct T6805
940 {
941     template opDispatch(string name)
942     {
943         alias int Type;
944     }
945 }
946 static assert(is(T6805.xxx.Type == int));
947 
948 /**********************************/
949 // https://issues.dlang.org/show_bug.cgi?id=6738
950 
951 struct Foo6738
952 {
953     int _val = 10;
954 
955     @property int val()() { return _val; }
956     int get() { return val; }  // fail
957 }
958 
959 void test6738()
960 {
961     Foo6738 foo;
962     auto x = foo.val;  // ok
963     assert(x == 10);
964     assert(foo.get() == 10);
965 }
966 
967 /**********************************/
968 // https://issues.dlang.org/show_bug.cgi?id=7498
969 
970 template IndexMixin(){
971     void insert(T)(T value){  }
972 }
973 
974 class MultiIndexContainer{
975     mixin IndexMixin!() index0;
976     class Index0{
977         void baburk(){
978             this.outer.index0.insert(1);
979         }
980     }
981 }
982 
983 /**********************************/
984 // https://issues.dlang.org/show_bug.cgi?id=6780
985 
986 @property int foo6780()(){ return 10; }
987 
988 int g6780;
989 @property void bar6780()(int n){ g6780 = n; }
990 
991 void test6780()
992 {
993     auto n = foo6780;
994     assert(n == 10);
995 
996     bar6780 = 10;
997     assert(g6780 == 10);
998 }
999 
1000 /**********************************/
1001 // https://issues.dlang.org/show_bug.cgi?id=6810
1002 
1003 int f6810(int n)(int) { return 1;}
1004 int f6810(U...)(U)    { assert(0); }
1005 int f6810(U...)(U a)  { assert(0); }
1006 int f6810(U...)(U)   if (true) { assert(0); }
1007 int f6810(U...)(U a) if (true) { assert(0); }
1008 
1009 void test6810()
1010 {
1011     assert(f6810!0(0) == 1);
1012 }
1013 
1014 /**********************************/
1015 // https://issues.dlang.org/show_bug.cgi?id=6891
1016 
1017 struct S6891(int N, T)
1018 {
1019     void f(U)(S6891!(N, U) u) { }
1020 }
1021 
1022 void test6891()
1023 {
1024     alias S6891!(1, void) A;
1025     A().f(A());
1026 }
1027 
1028 /**********************************/
1029 // https://issues.dlang.org/show_bug.cgi?id=6994
1030 
1031 struct Foo6994
1032 {
1033     T get(T)(){ return T.init; }
1034 
1035     T func1(T)()
1036     if (__traits(compiles, get!T()))
1037     { return get!T; }
1038 
1039     T func2(T)()
1040     if (__traits(compiles, this.get!T()))   // add explicit 'this'
1041     { return get!T; }
1042 }
1043 void test6994()
1044 {
1045     Foo6994 foo;
1046     foo.get!int();      // OK
1047     foo.func1!int();    // OK
1048     foo.func2!int();    // NG
1049 }
1050 
1051 /**********************************/
1052 // https://issues.dlang.org/show_bug.cgi?id=6764
1053 
1054 enum N6764 = 1; //use const for D1
1055 
1056 alias size_t[N6764] T6764; //workaround
1057 void f6764()(T6764 arr...) { }
1058 
1059 void g6764()(size_t[1] arr...) { }
1060 
1061 void h6764()(size_t[N6764] arr...) { }
1062 
1063 void test6764()
1064 {
1065     f6764(0);    //good
1066     g6764(0);    //good
1067     h6764!()(0); //good
1068     h6764(0);    //Error: template main.f() does not match any function template declaration
1069 }
1070 
1071 /**********************************/
1072 // https://issues.dlang.org/show_bug.cgi?id=3467
1073 // https://issues.dlang.org/show_bug.cgi?id=6806
1074 
1075 struct Foo3467( uint n )
1076 {
1077     Foo3467!( n ) bar( ) {
1078         typeof( return ) result;
1079         return result;
1080     }
1081 }
1082 struct Vec3467(size_t N)
1083 {
1084     void opBinary(string op:"~", size_t M)(Vec3467!M) {}
1085 }
1086 void test3467()
1087 {
1088     Foo3467!( 4 ) baz;
1089     baz = baz.bar;// FAIL
1090 
1091     Vec3467!2 a1;
1092     Vec3467!3 a2;
1093     a1 ~ a2; // line 7, Error
1094 }
1095 
1096 struct TS6806(uint n) { pragma(msg, typeof(n)); }
1097 static assert(is(TS6806!(1u) == TS6806!(1)));
1098 
1099 /**********************************/
1100 // https://issues.dlang.org/show_bug.cgi?id=4413
1101 
1102 struct Foo4413
1103 {
1104     alias typeof(this) typeof_this;
1105     void bar1(typeof_this other) {}
1106     void bar2()(typeof_this other) {}
1107     void bar3(typeof(this) other) {}
1108     void bar4()(typeof(this) other) {}
1109 }
1110 
1111 void test4413()
1112 {
1113     Foo4413 f;
1114     f.bar1(f); // OK
1115     f.bar2(f); // OK
1116     f.bar3(f); // OK
1117     f.bar4(f); // ERR
1118 }
1119 
1120 /**********************************/
1121 // https://issues.dlang.org/show_bug.cgi?id=4675
1122 
1123 template isNumeric(T)
1124 {
1125     enum bool test1 = is(T : long);     // should be hidden
1126     enum bool test2 = is(T : real);     // should be hidden
1127     enum bool isNumeric = test1 || test2;
1128 }
1129 void test4675()
1130 {
1131     static assert( isNumeric!int);
1132     static assert(!isNumeric!string);
1133     static assert(!__traits(compiles, isNumeric!int.test1));   // should be an error
1134     static assert(!__traits(compiles, isNumeric!int.test2));   // should be an error
1135     static assert(!__traits(compiles, isNumeric!int.isNumeric));
1136 }
1137 
1138 /**********************************/
1139 // https://issues.dlang.org/show_bug.cgi?id=5525
1140 
1141 template foo5525(T)
1142 {
1143     T foo5525(T t)      { return t; }
1144     T foo5525(T t, T u) { return t + u; }
1145 }
1146 
1147 void test5525()
1148 {
1149     alias foo5525!int f;
1150     assert(f(1) == 1);
1151     assert(f(1, 2) == 3);
1152 }
1153 
1154 /**********************************/
1155 // https://issues.dlang.org/show_bug.cgi?id=5801
1156 
1157 int a5801;
1158 void bar5801(T = double)(typeof(a5801) i) {}
1159 void baz5801(T)(typeof(a5801) i, T t) {}
1160 void test5801()
1161 {
1162     bar5801(2);  // Does not compile.
1163     baz5801(3, "baz"); // Does not compile.
1164 }
1165 
1166 /**********************************/
1167 // https://issues.dlang.org/show_bug.cgi?id=5832
1168 
1169 struct Bar5832(alias v) {}
1170 
1171 template isBar5832a(T)
1172 {
1173     static if (is(T _ : Bar5832!(v), alias v))
1174         enum isBar5832a = true;
1175     else
1176         enum isBar5832a = false;
1177 }
1178 template isBar5832b(T)
1179 {
1180     static if (is(T _ : Bar5832!(v), alias int v))
1181         enum isBar5832b = true;
1182     else
1183         enum isBar5832b = false;
1184 }
1185 template isBar5832c(T)
1186 {
1187     static if (is(T _ : Bar5832!(v), alias string v))
1188         enum isBar5832c = true;
1189     else
1190         enum isBar5832c = false;
1191 }
1192 static assert( isBar5832a!(Bar5832!1234));
1193 static assert( isBar5832b!(Bar5832!1234));
1194 static assert(!isBar5832c!(Bar5832!1234));
1195 
1196 /**********************************/
1197 // https://issues.dlang.org/show_bug.cgi?id=2550
1198 
1199 template pow10_2550(long n)
1200 {
1201     const long pow10_2550 = 0;
1202     static if (n < 0)
1203         const long pow10_2550 = 0;
1204     else
1205         const long pow10_2550 = 10 * pow10_2550!(n - 1);
1206 }
1207 template pow10_2550(long n:0)
1208 {
1209     const long pow10_2550 = 1;
1210 }
1211 static assert(pow10_2550!(0) == 1);
1212 
1213 /**********************************/
1214 // [2.057] Remove top const in IFTI, 9198
1215 
1216 void foo10a(T   )(T)            { static assert(is(T    == const(int)[])); }
1217 void foo10b(T...)(T)            { static assert(is(T[0] == const(int)[])); }
1218 
1219 // ref parameter doesn't remove top const
1220 void boo10a(T   )(ref T)        { static assert(is(T    == const(int[]))); }
1221 void boo10b(T...)(ref T)        { static assert(is(T[0] == const(int[]))); }
1222 
1223 // auto ref with lvalue doesn't
1224 void goo10a(T   )(auto ref T)   { static assert(is(T    == const(int[]))); }
1225 void goo10b(T...)(auto ref T)   { static assert(is(T[0] == const(int[]))); }
1226 
1227 // auto ref with rvalue does
1228 void hoo10a(T   )(auto ref T)   { static assert(is(T    == const(int)[])); }
1229 void hoo10b(T...)(auto ref T)   { static assert(is(T[0] == const(int)[])); }
1230 
1231 void bar10a(T   )(T)            { static assert(is(T    == const(int)*)); }
1232 void bar10b(T...)(T)            { static assert(is(T[0] == const(int)*)); }
1233 
1234 void test10()
1235 {
1236     const a = [1,2,3];
1237     static assert(is(typeof(a) == const(int[])));
1238     foo10a(a);
1239     foo10b(a);
1240     boo10a(a);
1241     boo10b(a);
1242     goo10a(a);
1243     goo10b(a);
1244     hoo10a(cast(const)[1,2,3]);
1245     hoo10b(cast(const)[1,2,3]);
1246 
1247     int n;
1248     const p = &n;
1249     static assert(is(typeof(p) == const(int*)));
1250     bar10a(p);
1251     bar10b(p);
1252 }
1253 
1254 /**********************************/
1255 // https://issues.dlang.org/show_bug.cgi?id=3092
1256 
1257 template Foo3092(A...)
1258 {
1259     alias A[0] Foo3092;
1260 }
1261 static assert(is(Foo3092!(int, "foo") == int));
1262 
1263 /**********************************/
1264 // https://issues.dlang.org/show_bug.cgi?id=7037
1265 
1266 struct Foo7037 {}
1267 struct Bar7037 { Foo7037 f; alias f this; }
1268 void works7037( T )( T value ) if ( is( T : Foo7037 ) ) {}
1269 void doesnotwork7037( T : Foo7037 )( T value ) {}
1270 
1271 void test7037()
1272 {
1273    Bar7037 b;
1274    works7037( b );
1275    doesnotwork7037( b );
1276 }
1277 
1278 /**********************************/
1279 // https://issues.dlang.org/show_bug.cgi?id=7110
1280 
1281 struct S7110
1282 {
1283     int opSlice(int, int) const { return 0; }
1284     int opSlice()         const { return 0; }
1285     int opIndex(int, int) const { return 0; }
1286     int opIndex(int)      const { return 0; }
1287 }
1288 
1289 enum e7110 = S7110();
1290 
1291 template T7110(alias a) { } // or T7110(a...)
1292 
1293 alias T7110!( S7110 ) T71100; // passes
1294 alias T7110!((S7110)) T71101; // passes
1295 
1296 alias T7110!( S7110()[0..0]  )  A0; // passes
1297 alias T7110!(  (e7110[0..0]) )  A1; // passes
1298 alias T7110!(   e7110[0..0]  )  A2; // passes
1299 
1300 alias T7110!( S7110()[0, 0]  ) B0; // passes
1301 alias T7110!(  (e7110[0, 0]) ) B1; // passes
1302 alias T7110!(   e7110[0, 0]  ) B2; // passes
1303 
1304 alias T7110!( S7110()[]  ) C0; // passes
1305 alias T7110!(  (e7110[]) ) C1; // passes
1306 alias T7110!(   e7110[]  ) C2; // fails: e7110 is used as a type
1307 
1308 alias T7110!( S7110()[0]  ) D0; // passes
1309 alias T7110!(  (e7110[0]) ) D1; // passes
1310 alias T7110!(   e7110[0]  ) D2; // fails: e7110 must be an array or pointer type, not S7110
1311 
1312 /**********************************/
1313 // https://issues.dlang.org/show_bug.cgi?id=7124
1314 
1315 template StaticArrayOf(T : E[dim], E, size_t dim)
1316 {
1317     pragma(msg, "T = ", T, ", E = ", E, ", dim = ", dim);
1318     alias E[dim] StaticArrayOf;
1319 }
1320 
1321 template DynamicArrayOf(T : E[], E)
1322 {
1323     pragma(msg, "T = ", T, ", E = ", E);
1324     alias E[] DynamicArrayOf;
1325 }
1326 
1327 template AssocArrayOf(T : V[K], K, V)
1328 {
1329     pragma(msg, "T = ", T, ", K = ", K, ", V = ", V);
1330     alias V[K] AssocArrayOf;
1331 }
1332 void test7124()
1333 {
1334     struct SA { int[5] sa; alias sa this; }
1335     static assert(is(StaticArrayOf!SA == int[5]));
1336 
1337     struct DA { int[] da; alias da this; }
1338     static assert(is(DynamicArrayOf!DA == int[]));
1339 
1340     struct AA { int[string] aa; alias aa this; }
1341     static assert(is(AssocArrayOf!AA == int[string]));
1342 }
1343 
1344 /**********************************/
1345 // https://issues.dlang.org/show_bug.cgi?id=7359
1346 
1347 bool foo7359(T)(T[] a ...)
1348 {
1349     return true;
1350 }
1351 
1352 void test7359()
1353 {
1354     assert(foo7359(1,1,1,1,1,1));               // OK
1355     assert(foo7359("abc","abc","abc","abc"));   // NG
1356 }
1357 
1358 /**********************************/
1359 // https://issues.dlang.org/show_bug.cgi?id=7363
1360 
1361 template t7363()
1362 {
1363    enum e = 0;
1364    static if (true)
1365        enum t7363 = 0;
1366 }
1367 static assert(!__traits(compiles, t7363!().t7363 == 0)); // Assertion fails
1368 static assert(t7363!() == 0); // Error: void has no value
1369 
1370 template u7363()
1371 {
1372    static if (true)
1373    {
1374        enum e = 0;
1375        enum u73631 = 0;
1376    }
1377    alias u73631 u7363;
1378 }
1379 static assert(!__traits(compiles, u7363!().u7363 == 0)); // Assertion fails
1380 static assert(u7363!() == 0); // Error: void has no value
1381 
1382 /**********************************/
1383 
1384 struct S4371(T ...) { }
1385 
1386 alias S4371!("hi!") t;
1387 
1388 static if (is(t U == S4371!(U))) { }
1389 
1390 /**********************************/
1391 // https://issues.dlang.org/show_bug.cgi?id=7416
1392 
1393 void t7416(alias a)() if(is(typeof(a())))
1394 {}
1395 
1396 void test7416() {
1397     void f() {}
1398     alias t7416!f x;
1399 }
1400 
1401 /**********************************/
1402 // https://issues.dlang.org/show_bug.cgi?id=7563
1403 
1404 class Test7563
1405 {
1406     void test(T, bool a = true)(T t)
1407     {
1408 
1409     }
1410 }
1411 
1412 void test7563()
1413 {
1414     auto test = new Test7563;
1415     pragma(msg, typeof(test.test!(int, true)).stringof);
1416     pragma(msg, typeof(test.test!(int)).stringof); // Error: expression (test.test!(int)) has no type
1417 }
1418 
1419 /**********************************/
1420 // https://issues.dlang.org/show_bug.cgi?id=7572
1421 
1422 class F7572
1423 {
1424     Tr fn7572(Tr, T...)(T t) { return 1; }
1425 }
1426 Tr Fn7572(Tr, T...)(T t) { return 2; }
1427 
1428 void test7572()
1429 {
1430     F7572 f = new F7572();
1431     int delegate() dg = &f.fn7572!int;
1432     assert(dg() == 1);
1433 
1434     int function() fn = &Fn7572!int;
1435     assert(fn() == 2);
1436 }
1437 
1438 /**********************************/
1439 // https://issues.dlang.org/show_bug.cgi?id=7580
1440 
1441 struct S7580(T)
1442 {
1443     void opAssign()(T value) {}
1444 }
1445 struct X7580(T)
1446 {
1447     private T val;
1448     @property ref inout(T) get()() inout { return val; }    // template
1449     alias get this;
1450 }
1451 struct Y7580(T)
1452 {
1453     private T val;
1454     @property ref auto get()() inout { return val; }        // template + auto return
1455     alias get this;
1456 }
1457 
1458 void test7580()
1459 {
1460     S7580!(int) s;
1461     X7580!int x;
1462     Y7580!int y;
1463     s = x;
1464     s = y;
1465 
1466     shared(X7580!int) sx;
1467     static assert(!__traits(compiles, s = sx));
1468 }
1469 
1470 /**********************************/
1471 // https://issues.dlang.org/show_bug.cgi?id=7585
1472 
1473 extern(C) alias void function() Callback;
1474 
1475 template W7585a(alias dg)
1476 {
1477     //pragma(msg, typeof(dg));
1478     extern(C) void W7585a() { dg(); }
1479 }
1480 
1481 void test7585()
1482 {
1483     static void f7585a(){}
1484     Callback cb1 = &W7585a!(f7585a);      // OK
1485     static assert(!__traits(compiles,
1486     {
1487         void f7585b(){}
1488         Callback cb2 = &W7585a!(f7585b);  // NG
1489     }));
1490 
1491     Callback cb3 = &W7585a!((){});              // NG -> OK
1492     Callback cb4 = &W7585a!(function(){});      // OK
1493     static assert(!__traits(compiles,
1494     {
1495         Callback cb5 = &W7585a!(delegate(){});  // NG
1496     }));
1497 
1498     static int global;  // global data
1499     Callback cb6 = &W7585a!((){return global;});    // NG -> OK
1500     static assert(!__traits(compiles,
1501     {
1502         int n;
1503         Callback cb7 = &W7585a!((){return n;});     // NG
1504     }));
1505 }
1506 
1507 /**********************************/
1508 // https://issues.dlang.org/show_bug.cgi?id=7643
1509 
1510 template T7643(A...){ alias A T7643; }
1511 
1512 alias T7643!(long, "x", string, "y") Specs7643;
1513 
1514 alias T7643!( Specs7643[] ) U7643;  // Error: tuple A is used as a type
1515 
1516 /**********************************/
1517 // https://issues.dlang.org/show_bug.cgi?id=7671
1518 
1519        inout(int)[3]  id7671n1             ( inout(int)[3] );
1520        inout( U )[n]  id7671x1(U, size_t n)( inout( U )[n] );
1521 
1522 shared(inout int)[3]  id7671n2             ( shared(inout int)[3] );
1523 shared(inout  U )[n]  id7671x2(U, size_t n)( shared(inout  U )[n] );
1524 
1525 void test7671()
1526 {
1527     static assert(is( typeof( id7671n1( (immutable(int)[3]).init ) ) == immutable(int[3]) ));
1528     static assert(is( typeof( id7671x1( (immutable(int)[3]).init ) ) == immutable(int[3]) ));
1529 
1530     static assert(is( typeof( id7671n2( (immutable(int)[3]).init ) ) == immutable(int[3]) ));
1531     static assert(is( typeof( id7671x2( (immutable(int)[3]).init ) ) == immutable(int[3]) ));
1532 }
1533 
1534 /************************************/
1535 // https://issues.dlang.org/show_bug.cgi?id=7672
1536 
1537 T foo7672(T)(T a){ return a; }
1538 
1539 void test7672(inout(int[]) a = null, inout(int*) p = null)
1540 {
1541     static assert(is( typeof(        a ) == inout(int[]) ));
1542     static assert(is( typeof(foo7672(a)) == inout(int)[] ));
1543 
1544     static assert(is( typeof(        p ) == inout(int*) ));
1545     static assert(is( typeof(foo7672(p)) == inout(int)* ));
1546 }
1547 
1548 /**********************************/
1549 // https://issues.dlang.org/show_bug.cgi?id=7684
1550 
1551        U[]  id7684(U)(        U[]  );
1552 shared(U[]) id7684(U)( shared(U[]) );
1553 
1554 void test7684()
1555 {
1556     shared(int)[] x;
1557     static assert(is( typeof(id7684(x)) == shared(int)[] ));
1558 }
1559 
1560 /**********************************/
1561 // https://issues.dlang.org/show_bug.cgi?id=7694
1562 
1563 void match7694(alias m)()
1564 {
1565     m.foo();    //removing this line suppresses ice in both cases
1566 }
1567 
1568 struct T7694
1569 {
1570     void foo(){}
1571     void bootstrap()
1572     {
1573     //next line causes ice
1574         match7694!(this)();
1575     //while this works:
1576         alias this p;
1577         match7694!(p)();
1578     }
1579 }
1580 
1581 /**********************************/
1582 // https://issues.dlang.org/show_bug.cgi?id=7755
1583 
1584 template to7755(T)
1585 {
1586     T to7755(A...)(A args)
1587     {
1588         return toImpl7755!T(args);
1589     }
1590 }
1591 
1592 T toImpl7755(T, S)(S value)
1593 {
1594     return T.init;
1595 }
1596 
1597 template Foo7755(T){}
1598 
1599 struct Bar7755
1600 {
1601     void qux()
1602     {
1603         if (is(typeof(to7755!string(Foo7755!int)))){}
1604     }
1605 }
1606 
1607 /**********************************/
1608 
1609              U[]   id11a(U)(              U[]   );
1610        inout(U)[]  id11a(U)(        inout(U)[]  );
1611        inout(U[])  id11a(U)(        inout(U[])  );
1612 inout(shared(U[])) id11a(U)( inout(shared(U[])) );
1613 
1614 void test11a(inout int _ = 0)
1615 {
1616     shared(const(int))[] x;
1617     static assert(is( typeof(id11a(x)) == shared(const(int))[] ));
1618 
1619     shared(int)[] y;
1620     static assert(is( typeof(id11a(y)) == shared(int)[] ));
1621 
1622     inout(U)[n] idz(U, size_t n)( inout(U)[n] );
1623 
1624     inout(shared(bool[1])) z;
1625     static assert(is( typeof(idz(z)) == inout(shared(bool[1])) ));
1626 }
1627 
1628 inout(U[]) id11b(U)( inout(U[]) );
1629 
1630 void test11b()
1631 {
1632     alias const(shared(int)[]) T;
1633     static assert(is(typeof(id11b(T.init)) == const(shared(int)[])));
1634 }
1635 
1636 /**********************************/
1637 // https://issues.dlang.org/show_bug.cgi?id=7769
1638 
1639 void f7769(K)(inout(K) value){}
1640 void test7769()
1641 {
1642     f7769("abc");
1643 }
1644 
1645 /**********************************/
1646 // https://issues.dlang.org/show_bug.cgi?id=7812
1647 
1648 template A7812(T...) {}
1649 
1650 template B7812(alias C) if (C) {}
1651 
1652 template D7812()
1653 {
1654     alias B7812!(A7812!(NonExistent!())) D7812;
1655 }
1656 
1657 static assert(!__traits(compiles, D7812!()));
1658 
1659 /**********************************/
1660 // https://issues.dlang.org/show_bug.cgi?id=7873
1661 
1662 inout(T)* foo(T)(inout(T)* t)
1663 {
1664     static assert(is(T == int*));
1665     return t;
1666 }
1667 
1668 inout(T)* bar(T)(inout(T)* t)
1669 {
1670     return foo(t);
1671 }
1672 
1673 void test7873()
1674 {
1675     int *i;
1676     bar(&i);
1677 }
1678 
1679 /**********************************/
1680 // https://issues.dlang.org/show_bug.cgi?id=7933
1681 
1682 struct Boo7933(size_t dim){int a;}
1683 struct Baa7933(size_t dim)
1684 {
1685     Boo7933!dim a;
1686     //Boo7933!1 a; //(1) This version causes no errors
1687 }
1688 
1689 auto foo7933()(Boo7933!1 b){return b;}
1690 //auto fuu7933(Boo7933!1 b){return b;} //(2) This line neutralizes the error
1691 
1692 void test7933()
1693 {
1694     Baa7933!1 a; //(3) This line causes the error message
1695     auto b = foo7933(Boo7933!1(1));
1696 }
1697 
1698 /**********************************/
1699 // https://issues.dlang.org/show_bug.cgi?id=8094
1700 
1701 struct Tuple8094(T...) {}
1702 
1703 template getParameters8094(T, alias P)
1704 {
1705     static if (is(T t == P!U, U...))
1706         alias U getParameters8094;
1707     else
1708         static assert(false);
1709 }
1710 
1711 void test8094()
1712 {
1713     alias getParameters8094!(Tuple8094!(int, string), Tuple8094) args;
1714 }
1715 
1716 /**********************************/
1717 
1718 struct Tuple12(T...)
1719 {
1720     void foo(alias P)()
1721     {
1722         alias Tuple12 X;
1723         static if (is(typeof(this) t == X!U, U...))
1724             alias U getParameters;
1725         else
1726             static assert(false);
1727     }
1728 }
1729 
1730 void test12()
1731 {
1732     Tuple12!(int, string) t;
1733     t.foo!Tuple12();
1734 }
1735 
1736 /**********************************/
1737 // https://issues.dlang.org/show_bug.cgi?id=14290
1738 
1739 struct Foo14290(int i) {}
1740 alias Foo14290a = Foo14290!1;
1741 static assert(!is(Foo14290!2 == Foo14290a!T, T...));
1742 
1743 /**********************************/
1744 // https://issues.dlang.org/show_bug.cgi?id=8125
1745 
1746 void foo8125(){}
1747 
1748 struct X8125(alias a) {}
1749 
1750 template Y8125a(T : A!f, alias A, alias f) {}  //OK
1751 template Y8125b(T : A!foo8125, alias A) {}     //NG
1752 
1753 void test8125()
1754 {
1755     alias Y8125a!(X8125!foo8125) y1;
1756     alias Y8125b!(X8125!foo8125) y2;
1757 }
1758 
1759 /**********************************/
1760 
1761 struct A13() {}
1762 struct B13(TT...) {}
1763 struct C13(T1) {}
1764 struct D13(T1, TT...) {}
1765 struct E13(T1, T2) {}
1766 struct F13(T1, T2, TT...) {}
1767 
1768 template Test13(alias X)
1769 {
1770     static if (is(X x : P!U, alias P, U...))
1771         enum Test13 = true;
1772     else
1773         enum Test13 = false;
1774 }
1775 
1776 void test13()
1777 {
1778     static assert(Test13!( A13!() ));
1779     static assert(Test13!( B13!(int) ));
1780     static assert(Test13!( B13!(int, double) ));
1781     static assert(Test13!( B13!(int, double, string) ));
1782     static assert(Test13!( C13!(int) ));
1783     static assert(Test13!( D13!(int) ));
1784     static assert(Test13!( D13!(int, double) ));
1785     static assert(Test13!( D13!(int, double, string) ));
1786     static assert(Test13!( E13!(int, double) ));
1787     static assert(Test13!( F13!(int, double) ));
1788     static assert(Test13!( F13!(int, double, string) ));
1789     static assert(Test13!( F13!(int, double, string, bool) ));
1790 }
1791 
1792 /**********************************/
1793 
1794 struct A14(T, U, int n = 1)
1795 {
1796 }
1797 
1798 template Test14(alias X)
1799 {
1800     static if (is(X x : P!U, alias P, U...))
1801         alias U Test14;
1802     else
1803         static assert(0);
1804 }
1805 
1806 void test14()
1807 {
1808     alias A14!(int, double) Type;
1809     alias Test14!Type Params;
1810     static assert(Params.length == 3);
1811     static assert(is(Params[0] == int));
1812     static assert(is(Params[1] == double));
1813     static assert(   Params[2] == 1);
1814 }
1815 
1816 /**********************************/
1817 // test for evaluateConstraint assertion
1818 
1819 bool canSearchInCodeUnits15(C)(dchar c)
1820 if (is(C == char))
1821 {
1822     return true;
1823 }
1824 
1825 void test15()
1826 {
1827     int needle = 0;
1828     auto b = canSearchInCodeUnits15!char(needle);
1829 }
1830 
1831 /**********************************/
1832 // https://issues.dlang.org/show_bug.cgi?id=8129
1833 
1834 class X8129 {}
1835 class A8129 {}
1836 class B8129 : A8129 {}
1837 
1838 int foo8129(T : A8129)(X8129 x) { return 1; }
1839 int foo8129(T : A8129)(X8129 x, void function (T) block) { return 2; }
1840 
1841 int bar8129(T, R)(R range, T value) { return 1; }
1842 
1843 int baz8129(T, R)(R range, T value) { return 1; }
1844 int baz8129(T, R)(R range, Undefined value) { return 2; }
1845 
1846 void test8129()
1847 {
1848     auto x = new X8129;
1849     assert(x.foo8129!B8129()      == 1);
1850     assert(x.foo8129!B8129((a){}) == 2);
1851     assert(foo8129!B8129(x)        == 1);
1852     assert(foo8129!B8129(x, (a){}) == 2);
1853     assert(foo8129!B8129(x)              == 1);
1854     assert(foo8129!B8129(x, (B8129 b){}) == 2);
1855 
1856     ubyte[] buffer = [0, 1, 2];
1857     assert(bar8129!ushort(buffer, 915) == 1);
1858 
1859     // While deduction, parameter type 'Undefined' shows semantic error.
1860     static assert(!__traits(compiles, {
1861         baz8129!ushort(buffer, 915);
1862     }));
1863 }
1864 
1865 /**********************************/
1866 // https://issues.dlang.org/show_bug.cgi?id=8238
1867 
1868 void test8238()
1869 {
1870     static struct S { template t(){ int t; } }
1871 
1872     S s1, s2;
1873     assert(cast(void*)&s1      != cast(void*)&s2     );
1874     assert(cast(void*)&s1      != cast(void*)&s1.t!());
1875     assert(cast(void*)&s2      != cast(void*)&s2.t!());
1876     assert(cast(void*)&s1.t!() == cast(void*)&s2.t!());
1877     s1.t!() = 256;
1878     assert(s2.t!() == 256);
1879 }
1880 
1881 /**********************************/
1882 // https://issues.dlang.org/show_bug.cgi?id=8669
1883 
1884 struct X8669
1885 {
1886     void mfoo(this T)()
1887     {
1888         static assert(is(typeof(this) == T));
1889     }
1890     void cfoo(this T)() const
1891     {
1892         static assert(is(typeof(this) == const(T)));
1893     }
1894     void sfoo(this T)() shared
1895     {
1896         static assert(is(typeof(this) == shared(T)));
1897     }
1898     void scfoo(this T)() shared const
1899     {
1900         static assert(is(typeof(this) == shared(const(T))));
1901     }
1902     void ifoo(this T)() immutable
1903     {
1904         static assert(is(typeof(this) == immutable(T)));
1905     }
1906 }
1907 
1908 void test8669()
1909 {
1910                  X8669 mx;
1911            const X8669 cx;
1912       immutable  X8669 ix;
1913           shared X8669 sx;
1914     shared const X8669 scx;
1915 
1916      mx.mfoo();
1917      cx.mfoo();
1918      ix.mfoo();
1919      sx.mfoo();
1920     scx.mfoo();
1921 
1922      mx.cfoo();
1923      cx.cfoo();
1924      ix.cfoo();
1925      sx.cfoo();
1926     scx.cfoo();
1927 
1928     static assert(!is(typeof(  mx.sfoo() )));
1929     static assert(!is(typeof(  cx.sfoo() )));
1930      ix.sfoo();
1931      sx.sfoo();
1932     scx.sfoo();
1933 
1934     static assert(!is(typeof(  mx.scfoo() )));
1935     static assert(!is(typeof(  cx.scfoo() )));
1936      ix.scfoo();
1937      sx.scfoo();
1938     scx.scfoo();
1939 
1940     static assert(!is(typeof(  mx.ifoo() )));
1941     static assert(!is(typeof(  cx.ifoo() )));
1942      ix.ifoo();
1943     static assert(!is(typeof(  sx.ifoo() )));
1944     static assert(!is(typeof( scx.ifoo() )));
1945 }
1946 
1947 /**********************************/
1948 // https://issues.dlang.org/show_bug.cgi?id=8833
1949 
1950 template TypeTuple8833(T...) { alias TypeTuple = T; }
1951 
1952 void func8833(alias arg)() { }
1953 
1954 void test8833()
1955 {
1956     int x, y;
1957 
1958     alias TypeTuple8833!(
1959         func8833!(x),
1960         func8833!(y),
1961     ) Map;
1962 }
1963 
1964 /**********************************/
1965 // https://issues.dlang.org/show_bug.cgi?id=8976
1966 
1967 void f8976(ref int) { }
1968 
1969 void g8976()()
1970 {
1971     f8976(0); // line 5
1972 }
1973 
1974 
1975 void h8976()()
1976 {
1977     g8976!()();
1978 }
1979 
1980 static assert( __traits(compiles, h8976!()() ) ); // causes error
1981 static assert(is(typeof(          h8976!()() )));
1982 
1983 void test8976()
1984 {
1985     static assert( __traits(compiles, h8976!()() ) );
1986     static assert(is(typeof(          h8976!()() )));
1987 }
1988 
1989 /****************************************/
1990 // https://issues.dlang.org/show_bug.cgi?id=8940
1991 
1992 const int n8940; // or `immutable`
1993 static this() { n8940 = 3; }
1994 
1995 void f8940(T)(ref int val)
1996 {
1997     assert(val == 3);
1998     ++val;
1999 }
2000 
2001 static assert(!__traits(compiles,  f8940!void(n8940))); // fails
2002 void test8940()
2003 {
2004     assert(n8940 == 3);
2005     static assert(!__traits(compiles, f8940!void(n8940)));
2006     //assert(n8940 == 3); // may pass as compiler caches comparison result
2007     //assert(n8940 != 4); // may pass but likely will fail
2008 }
2009 
2010 /**********************************/
2011 // https://issues.dlang.org/show_bug.cgi?id=6969
2012 // https://issues.dlang.org/show_bug.cgi?id=8990
2013 
2014 class A6969() { alias C6969!() C1; }
2015 class B6969   { alias A6969!() A1; }
2016 class C6969() : B6969 {}
2017 
2018 struct A8990(T) { T t; }
2019 struct B8990(T) { A8990!T* a; }
2020 struct C8990    { B8990!C8990* b; }
2021 
2022 /**********************************/
2023 // https://issues.dlang.org/show_bug.cgi?id=9018
2024 
2025 template Inst9018(alias Template, T)
2026 {
2027     alias Template!T Inst;
2028 }
2029 
2030 template Template9018(T)
2031 {
2032     enum Template9018 = T;
2033 }
2034 
2035 static assert(!__traits(compiles, Inst9018!(Template9018, int))); // Assert passes
2036 static assert(!__traits(compiles, Inst9018!(Template9018, int))); // Assert fails
2037 
2038 /**********************************/
2039 // https://issues.dlang.org/show_bug.cgi?id=9022
2040 
2041 class C9022
2042 {
2043     struct X {}
2044 
2045     alias B = X;
2046 }
2047 class D9022
2048 {
2049     struct X {}
2050 }
2051 
2052 void test9022()
2053 {
2054     auto c = new C9022();
2055     auto d = new D9022();
2056     auto cx = C9022.X();
2057     auto dx = D9022.X();
2058 
2059     void foo1(T)(T, T.X) { static assert(is(T == C9022)); }
2060     void foo2(T)(T.X, T) { static assert(is(T == C9022)); }
2061     foo1(c, cx);
2062     foo2(cx, c);
2063 
2064     void hoo1(T)(T, T.B) { static assert(is(T == C9022)); }
2065     void hoo2(T)(T.B, T) { static assert(is(T == C9022)); }
2066     hoo1(c, cx);
2067     hoo1(c, cx);
2068 
2069     void bar1(alias A)(A.C9022, A.D9022) { static assert(A.stringof == "module breaker"); }
2070     void bar2(alias A)(A.D9022, A.C9022) { static assert(A.stringof == "module breaker"); }
2071     bar1(c, d);
2072     bar2(d, c);
2073 
2074     void var1(alias A)(A.C9022, A.D9022.X) { static assert(A.stringof == "module breaker"); }
2075     void var2(alias A)(A.D9022.X, A.C9022) { static assert(A.stringof == "module breaker"); }
2076     var1(c, dx);
2077     var2(dx, c);
2078 
2079     void baz(T)(T.X t, T.X u) { }
2080     static assert(!__traits(compiles, baz(cx, dx)));
2081 }
2082 
2083 /**********************************/
2084 // https://issues.dlang.org/show_bug.cgi?id=9026
2085 
2086 mixin template node9026()
2087 {
2088     static if (is(this == struct))
2089         alias typeof(this)* E;
2090     else
2091         alias typeof(this) E;
2092     E prev, next;
2093 }
2094 
2095 struct list9026(alias N)
2096 {
2097     N.E head;
2098     N.E tail;
2099 }
2100 
2101 class A9026
2102 {
2103     mixin node9026 L1;
2104     mixin node9026 L2;
2105 }
2106 
2107 list9026!(A9026.L1) g9026_l1;
2108 list9026!(A9026.L2) g9026_l2;
2109 
2110 void test9026()
2111 {
2112     list9026!(A9026.L1) l9026_l1;
2113     list9026!(A9026.L2) l9026_l2;
2114 }
2115 
2116 /**********************************/
2117 // https://issues.dlang.org/show_bug.cgi?id=9038
2118 
2119 mixin template Foo9038()
2120 {
2121     string data = "default";
2122 }
2123 
2124 class Bar9038
2125 {
2126     string data;
2127     mixin Foo9038 f;
2128 }
2129 
2130 void check_data9038(alias M, T)(T obj)
2131 {
2132     //writeln(M.stringof);
2133     assert(obj.data == "Bar");
2134     assert(obj.f.data == "F");
2135 }
2136 
2137 void test9038()
2138 {
2139     auto bar = new Bar9038;
2140     bar.data = "Bar";
2141     bar.f.data = "F";
2142 
2143     assert(bar.data == "Bar");
2144     assert(bar.f.data == "F");
2145 
2146     check_data9038!(Bar9038)(bar);
2147     check_data9038!(Bar9038.f)(bar);
2148     check_data9038!(bar.f)(bar);
2149 }
2150 
2151 /**********************************/
2152 // https://issues.dlang.org/show_bug.cgi?id=9050
2153 
2154 struct A9050(T) {}
2155 
2156 struct B9050(T)
2157 {
2158     void f() { foo9050(A9050!int()); }
2159 }
2160 
2161 auto foo9050()(A9050!int base) pure
2162 {
2163     return B9050!int();
2164 }
2165 
2166 auto s9050 = foo9050(A9050!int());
2167 
2168 /**********************************/
2169 // https://issues.dlang.org/show_bug.cgi?id=10936 (dup of 9050)
2170 
2171 struct Vec10936(string s)
2172 {
2173     auto foo(string v)()
2174     {
2175         return Vec10936!(v)();
2176     }
2177 
2178     static void bar()
2179     {
2180         Vec10936!"" v;
2181         auto p = v.foo!"sup";
2182     }
2183 }
2184 
2185 Vec10936!"" v;
2186 
2187 /**********************************/
2188 // https://issues.dlang.org/show_bug.cgi?id=9076
2189 
2190 template forward9076(args...)
2191 {
2192     @property forward9076()(){ return args[0]; }
2193 }
2194 
2195 void test9076()
2196 {
2197     int a = 1;
2198     int b = 1;
2199     assert(a == forward9076!b);
2200 }
2201 
2202 /**********************************/
2203 // https://issues.dlang.org/show_bug.cgi?id=9083
2204 
2205 template isFunction9083(X...) if (X.length == 1)
2206 {
2207     enum isFunction9083 = true;
2208 }
2209 
2210 struct S9083
2211 {
2212     static string func(alias Class)()
2213     {
2214         foreach (m; __traits(allMembers, Class))
2215         {
2216             pragma(msg, m);  // prints "func"
2217             enum x1 = isFunction9083!(mixin(m));  //NG
2218             enum x2 = isFunction9083!(func);      //OK
2219         }
2220         return "";
2221     }
2222 }
2223 enum nothing9083 = S9083.func!S9083();
2224 
2225 class C9083
2226 {
2227     int x;  // some class members
2228 
2229     void func()
2230     {
2231         void templateFunc(T)(const T obj)
2232         {
2233             enum x1 = isFunction9083!(mixin("x"));  // NG
2234             enum x2 = isFunction9083!(x);           // NG
2235         }
2236         templateFunc(this);
2237     }
2238 }
2239 
2240 /**********************************/
2241 // https://issues.dlang.org/show_bug.cgi?id=9100
2242 
2243 template Id(alias A) { alias Id = A; }
2244 template ErrId(alias A) { static assert(0); }
2245 template TypeTuple9100(TL...) { alias TypeTuple9100 = TL; }
2246 
2247 class C9100
2248 {
2249     int value;
2250 
2251     int fun() { return value; }
2252     int tfun(T)() { return value; }
2253     TypeTuple9100!(int, long) field;
2254 
2255     void test()
2256     {
2257         this.value = 1;
2258         auto c = new C9100();
2259         c.value = 2;
2260 
2261         alias t1a = Id!(c.fun);             // OK
2262         alias t1b = Id!(this.fun);          // Prints weird error, bad
2263         // -> internally given TOKdotvar
2264         assert(t1a() == this.value);
2265         assert(t1b() == this.value);
2266 
2267         alias t2a = Id!(c.tfun);            // OK
2268         static assert(!__traits(compiles, ErrId!(this.tfun)));
2269         alias t2b = Id!(this.tfun);         // No error occurs, why?
2270         // -> internally given TOKdottd
2271         assert(t2a!int() == this.value);
2272         assert(t2b!int() == this.value);
2273 
2274         alias t3a = Id!(foo9100);           // OK
2275         alias t3b = Id!(mixin("foo9100"));  // Prints weird error, bad
2276         // -> internally given TOKtemplate
2277         assert(t3a() == 10);
2278         assert(t3b() == 10);
2279 
2280         assert(field[0] == 0);
2281         alias t4a = TypeTuple9100!(field);              // NG
2282         alias t4b = TypeTuple9100!(GetField9100!());    // NG
2283         t4a[0] = 1; assert(field[0] == 1);
2284         t4b[0] = 2; assert(field[0] == 2);
2285     }
2286 }
2287 
2288 int foo9100()() { return 10; }
2289 template GetField9100() { alias GetField9100 = C9100.field[0]; }
2290 
2291 void test9100()
2292 {
2293     (new C9100()).test();
2294 }
2295 
2296 /**********************************/
2297 // https://issues.dlang.org/show_bug.cgi?id=9101
2298 
2299 class Node9101
2300 {
2301     template ForwardCtorNoId()
2302     {
2303         this() {} // default constructor
2304         void foo() { 0 = 1; }    // wrong code
2305     }
2306 }
2307 enum x9101 = __traits(compiles, Node9101.ForwardCtorNoId!());
2308 
2309 /**********************************/
2310 // https://issues.dlang.org/show_bug.cgi?id=9124
2311 
2312 struct Foo9124a(N...)
2313 {
2314     enum SIZE = N[0];
2315     private int _val;
2316 
2317     public void opAssign (T) (T other)
2318     if (is(T unused == Foo9124a!(_N), _N...))
2319     {
2320         _val = other._val;          // compile error
2321         this._val = other._val;     // explicit this make it work
2322     }
2323 
2324     public auto opUnary (string op) () if (op == "~") {
2325         Foo9124a!(SIZE) result = this;
2326         return result;
2327     }
2328 }
2329 void test9124a()
2330 {
2331     Foo9124a!(28) a;
2332     Foo9124a!(28) b = ~a;
2333 }
2334 
2335 // --------
2336 
2337 template Foo9124b(T, U, string OP)
2338 {
2339     enum N = T.SIZE;
2340     alias Foo9124b = Foo9124b!(false, true, N);
2341 }
2342 struct Foo9124b(bool S, bool L, N...)
2343 {
2344     enum SIZE = 5;
2345     long[1] _a = 0;
2346     void someFunction() const {
2347         auto data1 = _a;        // Does not compile
2348         auto data2 = this._a;   // <--- Compiles
2349     }
2350     auto opBinary(string op, T)(T) {
2351         Foo9124b!(typeof(this), T, op) test;
2352     }
2353 }
2354 void test9124b()
2355 {
2356     auto p = Foo9124b!(false, false, 5)();
2357     auto q = Foo9124b!(false, false, 5)();
2358     p|q;
2359     p&q;
2360 }
2361 
2362 /**********************************/
2363 // https://issues.dlang.org/show_bug.cgi?id=9143
2364 
2365 struct Foo9143a(bool S, bool L)
2366 {
2367     auto noCall() {
2368         Foo9143a!(S, false) x1;         // compiles if this line commented
2369         static if(S) Foo9143a!(true,  false) x2;
2370         else         Foo9143a!(false, false) x2;
2371     }
2372     this(T)(T other)        // constructor
2373     if (is(T unused == Foo9143a!(P, Q), bool P, bool Q)) { }
2374 }
2375 
2376 struct Foo9143b(bool L, size_t N)
2377 {
2378     void baaz0() {
2379         bar!(Foo9143b!(false, N))();    // line 7
2380         // -> move to before the baaz semantic
2381     }
2382     void baaz() {
2383         bar!(Foo9143b!(false, 2LU))();  // line 3
2384         bar!(Foo9143b!(true, 2LU))();   // line 4
2385         bar!(Foo9143b!(L, N))();        // line 5
2386         bar!(Foo9143b!(true, N))();     // line 6
2387         bar!(Foo9143b!(false, N))();    // line 7
2388     }
2389     void bar(T)()
2390     if (is(T unused == Foo9143b!(_L, _N), bool _L, size_t _N))
2391     {}
2392 }
2393 
2394 void test9143()
2395 {
2396     Foo9143a!(false, true) k = Foo9143a!(false, false)();
2397 
2398     auto p = Foo9143b!(true, 2LU)();
2399 }
2400 
2401 /**********************************/
2402 // https://issues.dlang.org/show_bug.cgi?id=9266
2403 
2404 template Foo9266(T...)
2405 {
2406     T Foo9266;
2407 }
2408 struct Bar9266()
2409 {
2410     alias Foo9266!int f;
2411 }
2412 void test9266()
2413 {
2414     Bar9266!() a, b;
2415 }
2416 
2417 /**********************************/
2418 // https://issues.dlang.org/show_bug.cgi?id=9361
2419 
2420 struct Unit9361(A)
2421 {
2422     void butPleaseDontUseMe()()
2423     if (is(unitType9361!((this))))  // !
2424     {}
2425 
2426 }
2427 template isUnit9361(alias T) if ( is(T)) {}
2428 template isUnit9361(alias T) if (!is(T)) {}
2429 
2430 template unitType9361(alias T) if (isUnit9361!T) {}
2431 
2432 void test9361()
2433 {
2434     Unit9361!int u;
2435     static assert(!__traits(compiles, u.butPleaseDontUseMe())); // crashes
2436 }
2437 
2438 /**********************************/
2439 // https://issues.dlang.org/show_bug.cgi?id=9536
2440 
2441 struct S9536
2442 {
2443     static A foo(A)(A a)
2444     {
2445         return a * 2;
2446     }
2447     int bar() const
2448     {
2449         return foo(42);
2450     }
2451 }
2452 
2453 void test9536()
2454 {
2455     S9536 s;
2456     assert(s.bar() == 84);
2457 }
2458 
2459 /**********************************/
2460 // https://issues.dlang.org/show_bug.cgi?id=9578
2461 
2462 template t9578(alias f) { void tf()() { f(); } }
2463 
2464 void g9578a(alias f)()  { f(); }        // Error -> OK
2465 void g9578b(alias ti)() { ti.tf(); }    // Error -> OK
2466 
2467 void test9578()
2468 {
2469     int i = 0;
2470     int m() { return i; }
2471 
2472     g9578a!(t9578!m.tf)();
2473     g9578b!(t9578!m)();
2474 }
2475 
2476 /**********************************/
2477 // https://issues.dlang.org/show_bug.cgi?id=9596
2478 
2479 int foo9596a(K, V)(inout(       V  [K])) { return 1; }
2480 int foo9596a(K, V)(inout(shared(V) [K])) { return 2; }
2481 
2482 int foo9596b(K, V)(inout(       V  [K])) { return 1; }
2483 int foo9596b(K, V)(inout( const(V) [K])) { return 3; }
2484 
2485 int foo9596c(K, V)(inout(shared(V) [K])) { return 2; }
2486 int foo9596c(K, V)(inout( const(V) [K])) { return 3; }
2487 
2488 int foo9596d(K, V)(inout(       V  [K])) { return 1; }
2489 int foo9596d(K, V)(inout(shared(V) [K])) { return 2; }
2490 int foo9596d(K, V)(inout( const(V) [K])) { return 3; }
2491 
2492 int foo9596e(K, V)(inout(shared(V) [K])) { return 2; }
2493 int foo9596e(K, V)(inout(       V  [K])) { return 1; }
2494 int foo9596e(K, V)(inout( const(V) [K])) { return 3; }
2495 
2496 void test9596()
2497 {
2498     shared(int)[int] aa;
2499     static assert(!__traits(compiles, foo9596a(aa)));
2500 
2501     assert(foo9596b(aa) == 1);
2502     assert(foo9596c(aa) == 2);
2503 
2504     static assert(!__traits(compiles, foo9596d(aa)));
2505     static assert(!__traits(compiles, foo9596e(aa)));
2506 }
2507 
2508 /******************************************/
2509 // https://issues.dlang.org/show_bug.cgi?id=9806
2510 
2511 struct S9806a(alias x)
2512 {
2513     alias S9806a!0 N;
2514 }
2515 enum expr9806a = 0 * 0;
2516 alias S9806a!expr9806a T9806a;
2517 
2518 // --------
2519 
2520 struct S9806b(alias x)
2521 {
2522     template Next()
2523     {
2524         enum expr = x + 1;
2525         alias S9806b!expr Next;
2526     }
2527 }
2528 alias S9806b!1 One9806b;
2529 alias S9806b!0.Next!() OneAgain9806b;
2530 
2531 // --------
2532 
2533 struct S9806c(x...)
2534 {
2535     template Next()
2536     {
2537         enum expr = x[0] + 1;
2538         alias S9806c!expr Next;
2539     }
2540 }
2541 alias S9806c!1 One9806c;
2542 alias S9806c!0.Next!() OneAgain9806c;
2543 
2544 /******************************************/
2545 // https://issues.dlang.org/show_bug.cgi?id=9837
2546 
2547 void test9837()
2548 {
2549     enum DA : int[] { a = [1,2,3] }
2550     DA da;
2551     int[] bda = da;
2552     static assert(is(DA : int[]));
2553     void fda1(int[] a) {}
2554     void fda2(T)(T[] a) {}
2555     fda1(da);
2556     fda2(da);
2557 
2558     enum SA : int[3] { a = [1,2,3] }
2559     SA sa;
2560     int[3] bsa = sa;
2561     static assert(is(SA : int[3]));
2562     void fsa1(int[3] a) {}
2563     void fsa2(T)(T[3] a) {}
2564     void fsa3(size_t d)(int[d] a) {}
2565     void fsa4(T, size_t d)(T[d] a) {}
2566     fsa1(sa);
2567     fsa2(sa);
2568     fsa3(sa);
2569     fsa4(sa);
2570 
2571     enum AA : int[int] { a = null }
2572     AA aa;
2573     int[int] baa = aa;
2574     static assert(is(AA : int[int]));
2575     void faa1(int[int] a) {}
2576     void faa2(V)(V[int] a) {}
2577     void faa3(K)(int[K] a) {}
2578     void faa4(K, V)(V[K] a) {}
2579     faa1(aa);
2580     faa2(aa);
2581     faa3(aa);
2582     faa4(aa);
2583 }
2584 
2585 /******************************************/
2586 // https://issues.dlang.org/show_bug.cgi?id=9874
2587 
2588 bool foo9874() { return true; }
2589 void bar9874(T)(T) if (foo9874()) {} // OK
2590 void baz9874(T)(T) if (foo9874)   {} // error
2591 
2592 void test9874()
2593 {
2594     foo9874;                      // OK
2595     bar9874(0);
2596     baz9874(0);
2597 }
2598 
2599 /******************************************/
2600 
2601 void test9885()
2602 {
2603     void foo(int[1][]) {}
2604     void boo()(int[1][]){}
2605     struct X(T...) { static void xoo(T){} }
2606     struct Y(T...) { static void yoo()(T){} }
2607     struct Z(T...) { static void zoo(U...)(T, U){} }
2608 
2609     struct V(T...) { static void voo()(T, ...){} }
2610     struct W(T...) { static void woo()(T...){} }
2611 
2612     struct R(T...) { static void roo(U...)(int, U, T){} }
2613 
2614     // OK
2615     foo([[10]]);
2616     boo([[10]]);
2617 
2618     // OK
2619     X!(int[1][]).xoo([[10]]);
2620 
2621     // NG!
2622     Y!().yoo();
2623     Y!(int).yoo(1);
2624     Y!(int, int[]).yoo(1, [10]);
2625     static assert(!__traits(compiles, Y!().yoo(1)));
2626     static assert(!__traits(compiles, Y!(int).yoo("a")));
2627     static assert(!__traits(compiles, Y!().yoo!(int)()));
2628 
2629     // NG!
2630     Z!().zoo();
2631     Z!().zoo([1], [1:1]);
2632     Z!(int, string).zoo(1, "a");
2633     Z!(int, string).zoo(1, "a", [1], [1:1]);
2634     Z!().zoo!()();
2635     static assert(!__traits(compiles, Z!().zoo!()(1)));     // (none) <- 1
2636     static assert(!__traits(compiles, Z!(int).zoo!()()));   // int <- (none)
2637     static assert(!__traits(compiles, Z!(int).zoo!()(""))); // int <- ""
2638     static assert(!__traits(compiles, Z!().zoo!(int)()));   // int <- (none)
2639     static assert(!__traits(compiles, Z!().zoo!(int)(""))); // int <- ""
2640 
2641     V!().voo(1,2,3);
2642     V!(int).voo(1,2,3);
2643     V!(int, long).voo(1,2,3);
2644     static assert(!__traits(compiles, V!(int).voo()));          // int <- (none)
2645     static assert(!__traits(compiles, V!(int, long).voo(1)));       // long <- (none)
2646     static assert(!__traits(compiles, V!(int, string).voo(1,2,3)));     // string <- 2
2647 
2648     W!().woo();
2649     //W!().woo(1, 2, 3);    // Access Violation
2650     {   // this behavior is consistent with:
2651         //alias TL = TypeTuple!();
2652         //void foo(TL...) {}
2653         //foo(1, 2, 3);     // Access Violation
2654         //pragma(msg, typeof(foo));   // void(...)  -> D-style variadic function?
2655     }
2656     W!(int,int[]).woo(1,2,3);
2657     W!(int,int[2]).woo(1,2,3);
2658     static assert(!__traits(compiles, W!(int,int,int).woo(1,2,3)));     // int... <- 2
2659     static assert(!__traits(compiles, W!(int,int).woo(1,2)));           // int... <- 2
2660     static assert(!__traits(compiles, W!(int,int[2]).woo(1,2)));    // int[2]... <- 2
2661 
2662     R!().roo(1, "", []);
2663     R!(int).roo(1, "", [], 1);
2664     R!(int, string).roo(1, "", [], 1, "");
2665     R!(int, string).roo(1, 2, "");
2666     static assert(!__traits(compiles, R!(int).roo(1, "", []))); // int <- []
2667     static assert(!__traits(compiles, R!(int, int).roo(1, "", [])));    // int <- []
2668     static assert(!__traits(compiles, R!(int, string).roo(1, 2, 3)));   // string <- 3
2669 
2670     // test case
2671     struct Tuple(T...) { this()(T values) {} }
2672     alias T = Tuple!(int[1][]);
2673     auto t = T([[10]]);
2674 }
2675 
2676 /******************************************/
2677 // https://issues.dlang.org/show_bug.cgi?id=9971
2678 
2679 void goo9971()()
2680 {
2681     auto g = &goo9971;
2682 }
2683 
2684 struct S9971
2685 {
2686     void goo()()
2687     {
2688         auto g = &goo;
2689         static assert(is(typeof(g) == delegate));
2690     }
2691 }
2692 
2693 void test9971()
2694 {
2695     goo9971!()();
2696 
2697     S9971.init.goo!()();
2698 }
2699 
2700 /******************************************/
2701 // https://issues.dlang.org/show_bug.cgi?id=9977
2702 
2703 void test9977()
2704 {
2705     struct S1(T) { T value; }
2706     auto func1(T)(T value) { return value; }
2707     static assert(is(S1!int == struct));
2708     assert(func1(10) == 10);
2709 
2710     template S2(T) { struct S2 { T value; } }
2711     template func2(T) { auto func2(T value) { return value; } }
2712     static assert(is(S2!int == struct));
2713     assert(func2(10) == 10);
2714 
2715     template X(T) { alias X = T[3]; }
2716     static assert(is(X!int == int[3]));
2717 
2718     int a;
2719     template Y(T) { alias Y = T[typeof(a)]; }
2720     static assert(is(Y!double == double[int]));
2721 
2722     int v = 10;
2723     template Z() { alias Z = v; }
2724     assert(v == 10);
2725     Z!() = 20;
2726     assert(v == 20);
2727 }
2728 
2729 /******************************************/
2730 
2731 enum T8848a(int[] a) = a;
2732 enum T8848b(int[int] b) = b;
2733 enum T8848c(void* c) = c;
2734 
2735 static assert(T8848a!([1,2,3]) == [1,2,3]);
2736 static assert(T8848b!([1:2,3:4]) == [1:2,3:4]);
2737 static assert(T8848c!(null) == null);
2738 
2739 /******************************************/
2740 // https://issues.dlang.org/show_bug.cgi?id=9990
2741 
2742 auto initS9990() { return "hi"; }
2743 
2744 class C9990(alias init) {}
2745 
2746 alias SC9990 = C9990!(initS9990);
2747 
2748 /******************************************/
2749 // https://issues.dlang.org/show_bug.cgi?id=10067
2750 
2751 struct assumeSize10067(alias F) {}
2752 
2753 template useItemAt10067(size_t idx, T)
2754 {
2755     void impl(){ }
2756 
2757     alias useItemAt10067 = assumeSize10067!(impl);
2758 }
2759 
2760 useItemAt10067!(0, char) mapS10067;
2761 
2762 /******************************************/
2763 // https://issues.dlang.org/show_bug.cgi?id=4072
2764 
2765 void bug4072(T)(T x)
2766     if (is(typeof(bug4072(x))))
2767 {}
2768 
2769 static assert(!is(typeof(bug4072(7))));
2770 
2771 /******************************************/
2772 // https://issues.dlang.org/show_bug.cgi?id=10074
2773 
2774 template foo10074(F)
2775 {
2776     enum foo10074 = false;
2777 }
2778 bool foo10074(F)(F f)
2779     if (foo10074!F)
2780 {
2781     return false;
2782 }
2783 
2784 static assert(!is(typeof(foo10074(1))));
2785 
2786 /******************************************/
2787 // https://issues.dlang.org/show_bug.cgi?id=10083
2788 
2789 // [a-c] IFTI can find syntactic eponymous member
2790 template foo10083a(T)
2791 {
2792     int foo10083a(double) { return 1; }
2793     int foo10083a(T) { return 2; }
2794 }
2795 template foo10083b(T)
2796 {
2797     int foo10083b(T) { return 1; }
2798     int foo10083b(T, T) { return 2; }
2799 }
2800 template foo10083c1(T)
2801 {
2802     int foo10083c1(T) { return 1; }
2803     static if (true) { int x; }
2804 }
2805 template foo10083c2(T)
2806 {
2807     int foo10083c2(T) { return 1; }
2808     static if (true) { int x; } else { int y; }
2809 }
2810 
2811 // [d-f] IFTI cannot find syntactic eponymous member
2812 template foo10083d1(T)
2813 {
2814     static if (true)
2815     {
2816         int foo10083d1(T) { return 1; }
2817     }
2818     else
2819     {
2820     }
2821 }
2822 template foo10083d2(T)
2823 {
2824     static if (true)
2825     {
2826     }
2827     else
2828     {
2829         int foo10083d2(T) { return 1; }
2830     }
2831 }
2832 template foo10083e(T)
2833 {
2834     static if (true)
2835     {
2836         int foo10083e(double arg) { return 1; }
2837     }
2838     int foo10083e(T arg) { return 2; }
2839 }
2840 template foo10083f(T)
2841 {
2842     static if (true)
2843     {
2844         int foo10083f(T) { return 1; }
2845     }
2846     else
2847     {
2848         int foo10083f(T) { return 2; }
2849     }
2850 }
2851 
2852 void test10083()
2853 {
2854     assert(foo10083a(1) == 2);
2855     assert(foo10083a!int(1) == 2);
2856     assert(foo10083a!int(1.0) == 1);
2857     static assert(!__traits(compiles, foo10083a!double(1)));
2858     static assert(!__traits(compiles, foo10083a!double(1.0)));
2859     static assert(!__traits(compiles, foo10083a!real(1)));
2860     assert(foo10083a!real(1.0) == 1);
2861     assert(foo10083a!real(1.0L) == 2);
2862 
2863     assert(foo10083b(2) == 1);
2864     assert(foo10083b(3, 4) == 2);
2865     static assert(!__traits(compiles, foo10083b(2, "")));
2866 
2867     assert(foo10083c1(1) == 1);
2868     assert(foo10083c2(1) == 1);
2869 
2870     static assert(!__traits(compiles, foo10083d1(2)));
2871     static assert(!__traits(compiles, foo10083d2(2)));
2872     static assert(!__traits(compiles, foo10083e(3)));
2873     static assert(!__traits(compiles, foo10083f(3)));
2874 }
2875 
2876 /******************************************/
2877 // https://issues.dlang.org/show_bug.cgi?id=10134
2878 
2879 template ReturnType10134(alias func)
2880 {
2881     static if (is(typeof(func) R == return))
2882         alias R ReturnType10134;
2883     else
2884         static assert(0);
2885 }
2886 
2887 struct Result10134(T) {}
2888 
2889 template getResultType10134(alias func)
2890 {
2891     static if(is(ReturnType10134!(func.exec) _ == Result10134!(T), T))
2892     {
2893         alias getResultType10134 = T;
2894     }
2895 }
2896 
2897 template f10134(alias func)
2898 {
2899     Result10134!(getResultType10134!(func)) exec(int i)
2900     {
2901         return typeof(return)();
2902     }
2903 }
2904 
2905 template a10134()
2906 {
2907     Result10134!(double) exec(int i)
2908     {
2909         return b10134!().exec(i);
2910     }
2911 }
2912 
2913 template b10134()
2914 {
2915     Result10134!(double) exec(int i)
2916     {
2917         return f10134!(a10134!()).exec(i);
2918     }
2919 }
2920 
2921 pragma(msg, getResultType10134!(a10134!()));
2922 
2923 /******************************************/
2924 // https://issues.dlang.org/show_bug.cgi?id=10313
2925 
2926 void test10313()
2927 {
2928     struct Nullable(T)
2929     {
2930         this()(inout T value) inout {}
2931     }
2932 
2933     struct S { S[] array; }
2934     S s;
2935     auto ns = Nullable!S(s);
2936 
2937     class C { C[] array; }
2938     C c;
2939     auto nc = Nullable!C(c);
2940 }
2941 
2942 /******************************************/
2943 // https://issues.dlang.org/show_bug.cgi?id=10498
2944 
2945 template triggerIssue10498a()
2946 {
2947     enum triggerIssue10498a = __traits(compiles, { T10498a; });
2948 }
2949 
2950 template PackedGenericTuple10498a(Args...)
2951 {
2952     alias Args Tuple;
2953     enum e = triggerIssue10498a!();
2954 }
2955 
2956 struct S10498a { }
2957 
2958 template T10498a()
2959 {
2960     alias PackedGenericTuple10498a!S10498a T10498a;
2961 }
2962 
2963 void test10498a()
2964 {
2965     alias T10498a!() t;
2966     static assert(is(t.Tuple[0])); // Fails -> OK
2967 }
2968 
2969 // --------
2970 
2971 template triggerIssue10498b(A...)
2972 {
2973     enum triggerIssue10498b = __traits(compiles, { auto a = A[0]; });
2974 }
2975 
2976 template PackedGenericTuple10498b(Args...)
2977 {
2978     alias Args Tuple;
2979     enum e = triggerIssue10498b!Args;
2980 }
2981 
2982 template T10498b()
2983 {
2984     struct S {} // The fact `S` is in `T` causes the problem
2985     alias PackedGenericTuple10498b!S T10498b;
2986 }
2987 
2988 void test10498b()
2989 {
2990     alias T10498b!() t;
2991     static assert(is(t.Tuple[0]));
2992 }
2993 
2994 /******************************************/
2995 // https://issues.dlang.org/show_bug.cgi?id=10537
2996 
2997 struct Iota10537
2998 {
2999     int s,e,i;
3000     mixin Yield10537!q{ ; };
3001 }
3002 
3003 auto skipStrings10537(T)(T source)
3004 {
3005     return "";
3006 }
3007 
3008 mixin template Yield10537(dstring code)
3009 {
3010     alias X = typeof({ enum x = rewriteCode10537(code); }());
3011 }
3012 
3013 dstring rewriteCode10537(dstring code)
3014 {
3015     skipStrings10537(code);  // IFTI causes forward reference
3016     return "";
3017 }
3018 
3019 /******************************************/
3020 // https://issues.dlang.org/show_bug.cgi?id=10558
3021 
3022 template Template10558() {}
3023 
3024 struct Struct10558(alias T){}
3025 
3026 alias bar10558 = foo10558!(Template10558!());
3027 
3028 template foo10558(alias T)
3029 {
3030     alias foobar = Struct10558!T;
3031 
3032     void fun()
3033     {
3034         alias a = foo10558!T;
3035     }
3036 }
3037 
3038 /******************************************/
3039 // https://issues.dlang.org/show_bug.cgi?id=10592
3040 
3041 void test10592()
3042 {
3043     struct A(E)
3044     {
3045         int put()(const(E)[] data)
3046         {
3047             return 1;
3048         }
3049 
3050         int put()(const(dchar)[] data) if (!is(E == dchar))
3051         {
3052             return 2;
3053         }
3054 
3055         int put(C)(const(C)[] data) if (!is(C == dchar) && !is(E == C))
3056         {
3057             return 3;
3058         }
3059     }
3060 
3061     A!char x;
3062     assert(x.put("abcde"c) == 1);   // OK: hit 1
3063     assert(x.put("abcde"w) == 3);   // NG: this should hit 3
3064     assert(x.put("abcde"d) == 2);   // OK: hit 2
3065 }
3066 
3067 /******************************************/
3068 // https://issues.dlang.org/show_bug.cgi?id=11242
3069 
3070 inout(T[]) fromString11242(T)(inout(char[]) s, T[] dst)
3071 {
3072     return s;
3073 }
3074 
3075 void test11242()
3076 {
3077     char[] a;
3078     fromString11242(a, a);
3079 }
3080 
3081 /******************************************/
3082 // https://issues.dlang.org/show_bug.cgi?id=10811
3083 
3084 void foo10811a(R1, R2)(R1, R2) {}
3085 template foo10811a(alias pred) { void foo10811a(R1, R2)(R1, R2) {} }
3086 
3087 template foo10811b(alias pred) { void foo10811b(R1, R2)(R1, R2) {} }
3088 void foo10811b(R1, R2)(R1, R2) {}
3089 
3090 void test10811()
3091 {
3092     foo10811a(1, 2);
3093     foo10811a!(a => a)(1, 2);
3094 
3095     foo10811b(1, 2);
3096     foo10811b!(a => a)(1, 2);
3097 }
3098 
3099 /******************************************/
3100 // https://issues.dlang.org/show_bug.cgi?id=10969
3101 
3102 template A10969(T, U...) { alias A10969 = T; }
3103 void foo10969(T, U...)(A10969!(T, U) a) {}
3104 
3105 template B10969(T, U) { alias B10969 = T; }
3106 void bar10969(T, U...)(B10969!(T, U[0]) a) {}
3107 
3108 void test10969()
3109 {
3110     foo10969!(int, float)(3);
3111     bar10969!(int, float)(3);
3112 }
3113 
3114 /******************************************/
3115 // https://issues.dlang.org/show_bug.cgi?id=11271
3116 
3117 struct SmartPtr11271(T)
3118 {
3119     ~this() {}
3120     void opAssign(U)(auto ref U rh) {}
3121 }
3122 
3123 void test11271()
3124 {
3125     SmartPtr11271!Object a;
3126     a = SmartPtr11271!Object();
3127 }
3128 
3129 /******************************************/
3130 // https://issues.dlang.org/show_bug.cgi?id=11533
3131 
3132 version (none)
3133 {
3134 struct S11533
3135 {
3136     void put(alias fun)() { fun!int(); }
3137 }
3138 void test11533a()
3139 {
3140     static void foo(T)() {}
3141     S11533 s;
3142     s.put!foo();
3143 }
3144 
3145 void test11533b()
3146 {
3147     static void bar(alias fun)() { fun(); }
3148     void nested() {}
3149     bar!nested();
3150 }
3151 
3152 void test11533c()
3153 {
3154     static struct Foo(alias fun)
3155     {
3156         auto call() { return fun(); }
3157     }
3158     int var = 1;
3159     auto getVar() { return var; }
3160     Foo!getVar foo;
3161     assert(foo.call() == var);
3162     var += 1;
3163     assert(foo.call() == var);
3164 }
3165 
3166 void test11533()
3167 {
3168     test11533a();
3169     test11533b();
3170     test11533c();
3171 }
3172 }
3173 else
3174 {
3175 void test11533()
3176 {
3177 }
3178 }
3179 
3180 /******************************************/
3181 // https://issues.dlang.org/show_bug.cgi?id=11553
3182 
3183 struct Pack11553(T ...)
3184 {
3185     alias Unpack = T;
3186     enum length = T.length;
3187 }
3188 
3189 template isPack11553(TList ...)
3190 {
3191     static if (TList.length == 1 && is(Pack11553!(TList[0].Unpack) == TList[0]))
3192     {
3193         enum isPack11553 = true;
3194     }
3195     else
3196     {
3197         enum isPack11553 = false;
3198     }
3199 }
3200 
3201 template PartialApply11553(alias T, uint argLoc, Arg ...)
3202     if (Arg.length == 1)
3203 {
3204     template PartialApply11553(L ...)
3205     {
3206         alias PartialApply11553 = T!(L[0 .. argLoc], Arg, L[argLoc .. $]);
3207     }
3208 }
3209 
3210 template _hasLength11553(size_t len, T)
3211 {
3212     static if (T.length == len)
3213     {
3214         enum _hasLength11553 = true;
3215     }
3216     else
3217     {
3218         enum _hasLength11553 = false;
3219     }
3220 }
3221 
3222 alias _hasLength11553(size_t len) = PartialApply11553!(._hasLength11553, 0, len);
3223 
3224 
3225 alias hl11553 = _hasLength11553!1;
3226 
3227 // this segfaults
3228 static if (!isPack11553!hl11553) { pragma(msg, "All good 1"); }
3229 
3230 // these are fine
3231 static if ( hl11553!(Pack11553!(5))) { pragma(msg, "All good 2"); }
3232 
3233 static if (!hl11553!(Pack11553!( ))) { pragma(msg, "All good 3"); }
3234 
3235 /******************************************/
3236 // https://issues.dlang.org/show_bug.cgi?id=11818
3237 
3238 enum E11818 { e0, e1 }
3239 
3240 struct SortedRange11818
3241 {
3242     void fun(E11818 e = true ? E11818.e0 : E11818.e1)()
3243     {
3244     }
3245 }
3246 
3247 void test11818()
3248 {
3249     SortedRange11818 s;
3250     s.fun();
3251 }
3252 
3253 /******************************************/
3254 // https://issues.dlang.org/show_bug.cgi?id=11843
3255 
3256 void test11843()
3257 {
3258     struct Foo
3259     {
3260         int[string] x;
3261     }
3262 
3263     struct Bar(alias foo) {}
3264 
3265     enum bar1 = Bar!(Foo(["a": 1]))();
3266     enum bar2 = Bar!(Foo(["a": 1]))();
3267     static assert(is(typeof(bar1) == typeof(bar2)));
3268 
3269     enum foo1 = Foo(["a": 1]);
3270     enum foo2 = Foo(["b": -1]);
3271     static assert(!__traits(isSame, foo1, foo2));
3272     enum bar3 = Bar!foo1();
3273     enum bar4 = Bar!foo2();
3274     static assert(!is(typeof(bar3) == typeof(bar4)));
3275 }
3276 
3277 /******************************************/
3278 // https://issues.dlang.org/show_bug.cgi?id=11872
3279 
3280 class Foo11872
3281 {
3282     auto test(int v)() {}
3283     auto test(int v)(string) {}
3284 
3285     template Bar(T)
3286     {
3287         void test(T) {}
3288     }
3289 }
3290 
3291 void test11872()
3292 {
3293     auto foo = new Foo11872();
3294 
3295     with (foo)
3296     {
3297         // ScopeExp(ti) -> DotTemplateInstanceExp(wthis, ti)
3298         foo.test!2();   // works
3299         test!2();       // works <- fails
3300         test!2;         // works <- fails
3301 
3302         // ScopeExp(ti) -> DotTemplateInstanceExp(wthis, ti) -> DotExp(wthis, ScopeExp)
3303         foo.Bar!int.test(1);    // works
3304         Bar!int.test(1);        // works <- fails
3305     }
3306 }
3307 
3308 /******************************************/
3309 // https://issues.dlang.org/show_bug.cgi?id=12042
3310 
3311 struct S12042
3312 {
3313     int[] t;
3314 
3315     void m()()
3316     {
3317         t = null;   // CTFE error -> OK
3318     }
3319 }
3320 
3321 int test12042()
3322 {
3323     S12042 s;
3324 
3325     with (s)
3326         m!()();
3327 
3328     return 1;
3329 }
3330 
3331 static assert(test12042());
3332 
3333 /******************************************/
3334 // https://issues.dlang.org/show_bug.cgi?id=12077
3335 
3336 struct S12077(A) {}
3337 
3338 alias T12077(alias T : Base!Args, alias Base, Args...) = Base;
3339 static assert(__traits(isSame, T12077!(S12077!int), S12077));
3340 
3341 alias U12077(alias T : Base!Args, alias Base, Args...) = Base;
3342 alias U12077(      T : Base!Args, alias Base, Args...) = Base;
3343 static assert(__traits(isSame, U12077!(S12077!int), S12077));
3344 
3345 /******************************************/
3346 // https://issues.dlang.org/show_bug.cgi?id=12262
3347 
3348 template Inst12262(T) { int x; }
3349 
3350 enum fqnSym12262(alias a)                      = 1;
3351 enum fqnSym12262(alias a : B!A, alias B, A...) = 2;
3352 
3353 static assert(fqnSym12262!(Inst12262!(Object)) == 2);
3354 static assert(fqnSym12262!(Inst12262!(Object).x) == 1);
3355 
3356 /******************************************/
3357 // https://issues.dlang.org/show_bug.cgi?id=12264
3358 
3359 struct S12264(A) {}
3360 
3361 template AX12264(alias A1)                      { enum AX12264 = 1; }
3362 template AX12264(alias A2 : B!A, alias B, A...) { enum AX12264 = 2; }
3363 template AY12264(alias A1)                  { enum AY12264 = 1; }
3364 template AY12264(alias A2 : B!int, alias B) { enum AY12264 = 2; }
3365 template AZ12264(alias A1)               { enum AZ12264 = 1; }
3366 template AZ12264(alias A2 : S12264!T, T) { enum AZ12264 = 2; }
3367 static assert(AX12264!(S12264!int) == 2);
3368 static assert(AY12264!(S12264!int) == 2);
3369 static assert(AZ12264!(S12264!int) == 2);
3370 
3371 template TX12264(T1)                      { enum TX12264 = 1; }
3372 template TX12264(T2 : B!A, alias B, A...) { enum TX12264 = 2; }
3373 template TY12264(T1)                  { enum TY12264 = 1; }
3374 template TY12264(T2 : B!int, alias B) { enum TY12264 = 2; }
3375 template TZ12264(T1)               { enum TZ12264 = 1; }
3376 template TZ12264(T2 : S12264!T, T) { enum TZ12264 = 2; }
3377 static assert(TX12264!(S12264!int) == 2);
3378 static assert(TY12264!(S12264!int) == 2);
3379 static assert(TZ12264!(S12264!int) == 2);
3380 
3381 /******************************************/
3382 // https://issues.dlang.org/show_bug.cgi?id=12122
3383 
3384 enum N12122 = 1;
3385 
3386 void foo12122(T)(T[N12122]) if(is(T == int)) {}
3387 
3388 void test12122()
3389 {
3390     int[N12122] data;
3391     foo12122(data);
3392 }
3393 
3394 /******************************************/
3395 // https://issues.dlang.org/show_bug.cgi?id=12186
3396 
3397 template map_front12186(fun...)
3398 {
3399     auto map_front12186(Range)(Range r)
3400     {
3401         return fun[0](r[0]);
3402     }
3403 }
3404 
3405 void test12186()
3406 {
3407     immutable int[][] mat;
3408 
3409     mat.map_front12186!((in r) => 0);              // OK
3410     mat.map_front12186!((const r) => 0);           // OK
3411     mat.map_front12186!((immutable int[] r) => 0); // OK
3412     mat.map_front12186!((immutable r) => 0);       // OK <- Error
3413 }
3414 
3415 /******************************************/
3416 // https://issues.dlang.org/show_bug.cgi?id=12207
3417 
3418 void test12207()
3419 {
3420     static struct S
3421     {
3422         static void f(T)(T) {}
3423     }
3424 
3425     immutable S s;
3426 
3427     s.f(1);
3428 }
3429 
3430 /******************************************/
3431 // https://issues.dlang.org/show_bug.cgi?id=12263
3432 
3433 template A12263(alias a) { int x; }
3434 template B12263(alias a) { int x; }
3435 
3436 template fqnSym12263(alias T : B12263!A, alias B12263, A...)
3437 {
3438     enum fqnSym12263 = true;
3439 }
3440 
3441 static assert(fqnSym12263!(A12263!(Object)));
3442 static assert(fqnSym12263!(B12263!(Object)));
3443 
3444 /******************************************/
3445 // https://issues.dlang.org/show_bug.cgi?id=12290
3446 
3447 void test12290()
3448 {
3449     short[] arrS;
3450     float[] arrF;
3451     double[] arrD;
3452     real[] arrR;
3453     string cstr;
3454     wstring wstr;
3455     dstring dstr;
3456     short[short] aa;
3457 
3458     auto func1a(E)(E[], E) { return E.init; }
3459     auto func1b(E)(E, E[]) { return E.init; }
3460 
3461     static assert(is(typeof(func1a(arrS, 1)) == short));
3462     static assert(is(typeof(func1b(1, arrS)) == short));
3463     static assert(is(typeof(func1a(arrF, 1.0)) == float));
3464     static assert(is(typeof(func1b(1.0, arrF)) == float));
3465     static assert(is(typeof(func1a(arrD, 1.0L)) == double));
3466     static assert(is(typeof(func1b(1.0L, arrD)) == double));
3467     static assert(is(typeof(func1a(arrR, 1)) == real));
3468     static assert(is(typeof(func1b(1, arrR)) == real));
3469     static assert(is(typeof(func1a("str" , 'a')) == immutable  char));
3470     static assert(is(typeof(func1b('a', "str" )) == immutable  char));
3471     static assert(is(typeof(func1a("str"c, 'a')) == immutable  char));
3472     static assert(is(typeof(func1b('a', "str"c)) == immutable  char));
3473     static assert(is(typeof(func1a("str"w, 'a')) == immutable wchar));
3474     static assert(is(typeof(func1b('a', "str"w)) == immutable wchar));
3475     static assert(is(typeof(func1a("str"d, 'a')) == immutable dchar));
3476     static assert(is(typeof(func1b('a', "str"d)) == immutable dchar));
3477     static assert(is(typeof(func1a([1,2,3], 1L)) == long));
3478     static assert(is(typeof(func1b(1L, [1,2,3])) == long));
3479     static assert(is(typeof(func1a([1,2,3], 1.5)) == double));
3480     static assert(is(typeof(func1b(1.5, [1,2,3])) == double));
3481     static assert(is(typeof(func1a(["a","b"], "s"c)) ==  string));
3482     static assert(is(typeof(func1b("s"c, ["a","b"])) ==  string));
3483     static assert(is(typeof(func1a(["a","b"], "s"w)) == wstring));
3484     static assert(is(typeof(func1b("s"w, ["a","b"])) == wstring));
3485     static assert(is(typeof(func1a(["a","b"], "s"d)) == dstring));
3486     static assert(is(typeof(func1b("s"d, ["a","b"])) == dstring));
3487 
3488     auto func2a(K, V)(V[K], K, V) { return V[K].init; }
3489     auto func2b(K, V)(V, K, V[K]) { return V[K].init; }
3490 
3491     static assert(is(typeof(func2a(aa, 1, 1)) == short[short]));
3492     static assert(is(typeof(func2b(1, 1, aa)) == short[short]));
3493     static assert(is(typeof(func2a([1:10,2:20,3:30], 1L, 10L)) == long[long]));
3494     static assert(is(typeof(func2b(1L, 10L, [1:20,2:20,3:30])) == long[long]));
3495 
3496     auto func3a(T)(T, T) { return T.init; }
3497     auto func3b(T)(T, T) { return T.init; }
3498 
3499     static assert(is(typeof(func3a(arrS, null)) == short[]));
3500     static assert(is(typeof(func3b(null, arrS)) == short[]));
3501     static assert(is(typeof(func3a(arrR, null)) == real[]));
3502     static assert(is(typeof(func3b(null, arrR)) == real[]));
3503     static assert(is(typeof(func3a(cstr, "str")) ==  string));
3504     static assert(is(typeof(func3b("str", cstr)) ==  string));
3505     static assert(is(typeof(func3a(wstr, "str")) == wstring));
3506     static assert(is(typeof(func3b("str", wstr)) == wstring));
3507     static assert(is(typeof(func3a(dstr, "str")) == dstring));
3508     static assert(is(typeof(func3b("str", dstr)) == dstring));
3509     static assert(is(typeof(func3a("str1" , "str2"c)) ==  string));
3510     static assert(is(typeof(func3b("str1"c, "str2" )) ==  string));
3511     static assert(is(typeof(func3a("str1" , "str2"w)) == wstring));
3512     static assert(is(typeof(func3b("str1"w, "str2" )) == wstring));
3513     static assert(is(typeof(func3a("str1" , "str2"d)) == dstring));
3514     static assert(is(typeof(func3b("str1"d, "str2" )) == dstring));
3515 
3516     inout(V) get(K, V)(inout(V[K]) aa, K key, lazy V defaultValue) { return V.init; }
3517 
3518     short[short] hash12220;
3519     short res12220 = get(hash12220, 1, 1);
3520 
3521     short[short] hash12221;
3522     enum Key12221 : short { a }
3523     get(hash12221, Key12221.a, Key12221.a);
3524 
3525     int[][string] mapping13026;
3526     int[] v = get(mapping13026, "test", []);
3527 }
3528 
3529 /******************************************/
3530 // https://issues.dlang.org/show_bug.cgi?id=12292
3531 
3532 void test12292()
3533 {
3534     void fun(T : string)(T data) {}
3535 
3536     ubyte[3] sa;
3537     static assert(!__traits(compiles, fun(sa)));
3538     static assert(!__traits(compiles, { alias f = fun!(ubyte[3]); }));
3539 }
3540 
3541 /******************************************/
3542 // https://issues.dlang.org/show_bug.cgi?id=12376
3543 
3544 static auto encode12376(size_t sz)(dchar ch) if (sz > 1)
3545 {
3546     undefined;
3547 }
3548 
3549 void test12376()
3550 {
3551     enum x = __traits(compiles, encode12376!2(x));
3552 }
3553 
3554 /******************************************/
3555 // https://issues.dlang.org/show_bug.cgi?id=12447
3556 
3557 enum   test12447(string str) = str; // [1]
3558 string test12447(T...)(T args) if (T.length) { return args[0]; }    // [2]
3559 
3560 // With [1]: The template parameter str cannot be be deduced -> no match
3561 // With [2]: T is deduced to a type tuple (string), then match to the function call.
3562 static assert(test12447("foo") == "foo");
3563 
3564 // With [1]: template parameter str is deduced to "bar", then match.
3565 // With [2]: T is deduced to an expression tuple ("bar"), but it will make invalid the function signature (T args).
3566 //           The failure should be masked silently and prefer the 1st version.
3567 static assert(test12447!("bar") == "bar");
3568 
3569 /******************************************/
3570 // https://issues.dlang.org/show_bug.cgi?id=12651
3571 
3572 alias TemplateArgsOf12651(alias T : Base!Args, alias Base, Args...) = Args;
3573 
3574 struct S12651(T) { }
3575 
3576 static assert(!__traits(compiles, TemplateArgsOf12651!(S12651!int, S, float)));
3577 
3578 /******************************************/
3579 // https://issues.dlang.org/show_bug.cgi?id=12719
3580 
3581 struct A12719
3582 {
3583     B12719!int b();
3584 }
3585 
3586 struct B12719(T)
3587 {
3588     A12719 a;
3589     void m()
3590     {
3591         auto v = B12719!T.init;
3592     }
3593 }
3594 
3595 // --------
3596 
3597 enum canDoIt12719(R) = is(typeof(W12719!R));
3598 
3599 struct W12719(R)
3600 {
3601     R r;
3602     static if (canDoIt12719!R) {}
3603 }
3604 
3605 W12719!int a12719;
3606 
3607 /******************************************/
3608 // https://issues.dlang.org/show_bug.cgi?id=12746
3609 
3610 template foo12746()
3611 {
3612     void bar()
3613     {
3614         static assert(!__traits(compiles, bar(1)));
3615     }
3616     alias foo12746 = bar;
3617 }
3618 
3619 void foo12746(int)
3620 {
3621     assert(0);
3622 }
3623 
3624 void test12746()
3625 {
3626     foo12746(); // instantiate
3627 }
3628 
3629 /******************************************/
3630 // https://issues.dlang.org/show_bug.cgi?id=12748
3631 
3632 void foo12748(S, C : typeof(S.init[0]))(S s, C c)
3633 {
3634 }
3635 
3636 void test12748()
3637 {
3638     foo12748("abc", 'd');
3639 }
3640 
3641 /******************************************/
3642 // https://issues.dlang.org/show_bug.cgi?id=9708
3643 
3644 struct S9708
3645 {
3646     void f()(inout(Object)) inout {}
3647 }
3648 
3649 void test9708()
3650 {
3651     S9708 s;
3652     s.f(new Object);
3653 }
3654 
3655 /******************************************/
3656 // https://issues.dlang.org/show_bug.cgi?id=12880
3657 
3658 void f12880(T)(in T value) { static assert(is(T == string)); }
3659 void test12880() { f12880(string.init); }
3660 
3661 /******************************************/
3662 // https://issues.dlang.org/show_bug.cgi?id=13087
3663 
3664 struct Vec13087
3665 {
3666     int x;
3667     void m()                      { auto n = component13087!(this, 'x'); }
3668     void c() const                { auto n = component13087!(this, 'x'); }
3669     void w() inout                { auto n = component13087!(this, 'x'); }
3670     void wc() inout const         { auto n = component13087!(this, 'x'); }
3671     void s() shared               { auto n = component13087!(this, 'x'); }
3672     void sc() shared const        { auto n = component13087!(this, 'x'); }
3673     void sw() shared inout        { auto n = component13087!(this, 'x'); }
3674     void swc() shared inout const { auto n = component13087!(this, 'x'); }
3675     void i() immutable            { auto n = component13087!(this, 'x'); }
3676 }
3677 
3678 template component13087(alias vec, char c)
3679 {
3680     alias component13087 = vec.x;
3681 }
3682 
3683 /******************************************/
3684 // https://issues.dlang.org/show_bug.cgi?id=13127
3685 
3686 /+void test13127(inout int = 0)
3687 {
3688                        int []   ma1;
3689                  const(int)[]   ca1;
3690                  const(int[])   ca2;
3691            inout(      int)[]  wma1;
3692            inout(      int[])  wma2;
3693            inout(const int)[]  wca1;
3694            inout(const int[])  wca2;
3695              immutable(int)[]   ia1;
3696              immutable(int[])   ia2;
3697     shared(            int)[]  sma1;
3698     shared(            int[])  sma2;
3699     shared(      const int)[]  sca1;
3700     shared(      const int[])  sca2;
3701     shared(inout       int)[] swma1;
3702     shared(inout       int[]) swma2;
3703     shared(inout const int)[] swca1;
3704     shared(inout const int[]) swca2;
3705 
3706     /* In all cases, U should be deduced to top-unqualified type.
3707      */
3708 
3709     /* Parameter is (shared) mutable
3710      */
3711     U f_m(U)(       U) { return null; }
3712     U fsm(U)(shared U) { return null; }
3713     // 9 * 2 - 1
3714     static assert(is(typeof(f_m(  ma1))  ==                    int []));
3715     static assert(is(typeof(f_m(  ca1))  ==              const(int)[]));
3716     static assert(is(typeof(f_m(  ca2))  ==              const(int)[]));
3717     static assert(is(typeof(f_m( wma1))  ==        inout(      int)[]));
3718     static assert(is(typeof(f_m( wma2))  ==        inout(      int)[]));
3719     static assert(is(typeof(f_m( wca1))  ==        inout(const int)[]));
3720     static assert(is(typeof(f_m( wca2))  ==        inout(const int)[]));
3721     static assert(is(typeof(f_m(  ia1))  ==          immutable(int)[]));
3722     static assert(is(typeof(f_m(  ia2))  ==          immutable(int)[]));
3723     static assert(is(typeof(f_m( sma1))  == shared(            int)[]));
3724     static assert(is(typeof(f_m( sma2))  == shared(            int)[]));  // <- shared(int[])
3725     static assert(is(typeof(f_m( sca1))  == shared(      const int)[]));
3726     static assert(is(typeof(f_m( sca2))  == shared(      const int)[]));  // <- shared(const(int)[])
3727     static assert(is(typeof(f_m(swma1))  == shared(inout       int)[]));
3728     static assert(is(typeof(f_m(swma2))  == shared(inout       int)[]));  // <- shared(inout(int[]))
3729     static assert(is(typeof(f_m(swca1))  == shared(inout const int)[]));
3730     static assert(is(typeof(f_m(swca2))  == shared(inout const int)[]));  // <- shared(inout(const(int))[])
3731     // 9 * 2 - 1
3732     static assert(is(typeof(fsm(  ma1))) == false);
3733     static assert(is(typeof(fsm(  ca1))) == false);
3734     static assert(is(typeof(fsm(  ca2))) == false);
3735     static assert(is(typeof(fsm( wma1))) == false);
3736     static assert(is(typeof(fsm( wma2))) == false);
3737     static assert(is(typeof(fsm( wca1))) == false);
3738     static assert(is(typeof(fsm( wca2))) == false);
3739     static assert(is(typeof(fsm(  ia1))) == false);
3740     static assert(is(typeof(fsm(  ia2))) == false);
3741     static assert(is(typeof(fsm( sma1))  == shared(            int)[]));  // <- NG
3742     static assert(is(typeof(fsm( sma2))  == shared(            int)[]));
3743     static assert(is(typeof(fsm( sca1))  == shared(      const int)[]));  // <- NG
3744     static assert(is(typeof(fsm( sca2))  == shared(      const int)[]));
3745     static assert(is(typeof(fsm(swma1))  == shared(inout       int)[]));  // <- NG
3746     static assert(is(typeof(fsm(swma2))  == shared(inout       int)[]));
3747     static assert(is(typeof(fsm(swca1))  == shared(inout const int)[]));  // <- NG
3748     static assert(is(typeof(fsm(swca2))  == shared(inout const int)[]));
3749 
3750     /* Parameter is (shared) const
3751      */
3752     U f_c(U)(       const U) { return null; }
3753     U fsc(U)(shared const U) { return null; }
3754     // 9 * 2 - 1
3755     static assert(is(typeof(f_c(  ma1))  ==                    int []));
3756     static assert(is(typeof(f_c(  ca1))  ==              const(int)[]));
3757     static assert(is(typeof(f_c(  ca2))  ==              const(int)[]));
3758     static assert(is(typeof(f_c( wma1))  ==        inout(      int)[]));
3759     static assert(is(typeof(f_c( wma2))  ==        inout(      int)[]));
3760     static assert(is(typeof(f_c( wca1))  ==        inout(const int)[]));
3761     static assert(is(typeof(f_c( wca2))  ==        inout(const int)[]));
3762     static assert(is(typeof(f_c(  ia1))  ==          immutable(int)[]));
3763     static assert(is(typeof(f_c(  ia2))  ==          immutable(int)[]));
3764     static assert(is(typeof(f_c( sma1))  == shared(            int)[]));
3765     static assert(is(typeof(f_c( sma2))  == shared(            int)[]));  // <- shared(int[])
3766     static assert(is(typeof(f_c( sca1))  == shared(      const int)[]));
3767     static assert(is(typeof(f_c( sca2))  == shared(      const int)[]));  // <- shared(const(int)[])
3768     static assert(is(typeof(f_c(swma1))  == shared(inout       int)[]));
3769     static assert(is(typeof(f_c(swma2))  == shared(inout       int)[]));  // shared(inout(int)[])
3770     static assert(is(typeof(f_c(swca1))  == shared(inout const int)[]));
3771     static assert(is(typeof(f_c(swca2))  == shared(inout const int)[]));  // shared(inout(const(int))[])
3772     // 9 * 2 - 1
3773     static assert(is(typeof(fsc(  ma1))) == false);
3774     static assert(is(typeof(fsc(  ca1))) == false);
3775     static assert(is(typeof(fsc(  ca2))) == false);
3776     static assert(is(typeof(fsc( wma1))) == false);
3777     static assert(is(typeof(fsc( wma2))) == false);
3778     static assert(is(typeof(fsc( wca1))) == false);
3779     static assert(is(typeof(fsc( wca2))) == false);
3780     static assert(is(typeof(fsc(  ia1))  ==          immutable(int)[]));  // <- NG
3781     static assert(is(typeof(fsc(  ia2))  ==          immutable(int)[]));  // <- NG
3782     static assert(is(typeof(fsc( sma1))  == shared(            int)[]));  // <- NG
3783     static assert(is(typeof(fsc( sma2))  == shared(            int)[]));
3784     static assert(is(typeof(fsc( sca1))  == shared(      const int)[]));  // <- NG
3785     static assert(is(typeof(fsc( sca2))  == shared(      const int)[]));
3786     static assert(is(typeof(fsc(swma1))  == shared(inout       int)[]));  // <- NG
3787     static assert(is(typeof(fsc(swma2))  == shared(inout       int)[]));
3788     static assert(is(typeof(fsc(swca1))  == shared(inout const int)[]));  // <- NG
3789     static assert(is(typeof(fsc(swca2))  == shared(inout const int)[]));
3790 
3791     /* Parameter is immutable
3792      */
3793     U fi(U)(immutable U) { return null; }
3794     // 9 * 2 - 1
3795     static assert(is(typeof(fi(  ma1))) == false);
3796     static assert(is(typeof(fi(  ca1))) == false);
3797     static assert(is(typeof(fi(  ca2))) == false);
3798     static assert(is(typeof(fi( wma1))) == false);
3799     static assert(is(typeof(fi( wma2))) == false);
3800     static assert(is(typeof(fi( wca1))) == false);
3801     static assert(is(typeof(fi( wca2))) == false);
3802     static assert(is(typeof(fi(  ia1))  == immutable(int)[]));  // <- NG
3803     static assert(is(typeof(fi(  ia2))  == immutable(int)[]));  // <- NG
3804     static assert(is(typeof(fi( sma1))) == false);
3805     static assert(is(typeof(fi( sma2))) == false);
3806     static assert(is(typeof(fi( sca1))) == false);
3807     static assert(is(typeof(fi( sca2))) == false);
3808     static assert(is(typeof(fi(swma1))) == false);
3809     static assert(is(typeof(fi(swma2))) == false);
3810     static assert(is(typeof(fi(swca1))) == false);
3811     static assert(is(typeof(fi(swca2))) == false);
3812 
3813     /* Parameter is (shared) inout
3814      */
3815     U f_w(U)(       inout U) { return null; }
3816     U fsw(U)(shared inout U) { return null; }
3817     // 9 * 2 - 1
3818     static assert(is(typeof(f_w(  ma1))  ==              int []));
3819     static assert(is(typeof(f_w(  ca1))  ==              int []));  // <- const(int)[]
3820     static assert(is(typeof(f_w(  ca2))  ==              int []));  // <- const(int)[]
3821     static assert(is(typeof(f_w( wma1))  ==              int []));  // <- inout(int)[]
3822     static assert(is(typeof(f_w( wma2))  ==              int []));  // <- inout(int)[]
3823     static assert(is(typeof(f_w( wca1))  ==        const(int)[]));  // <- inout(const(int))[]
3824     static assert(is(typeof(f_w( wca2))  ==        const(int)[]));  // <- inout(const(int))[]
3825     static assert(is(typeof(f_w(  ia1))  ==              int []));  // <- immutable(int)[]
3826     static assert(is(typeof(f_w(  ia2))  ==              int []));  // <- immutable(int)[]
3827     static assert(is(typeof(f_w( sma1))  == shared(      int)[]));
3828     static assert(is(typeof(f_w( sma2))  == shared(      int)[]));  // <- shared(int[])
3829     static assert(is(typeof(f_w( sca1))  == shared(      int)[]));  // <- shared(const(int))[]
3830     static assert(is(typeof(f_w( sca2))  == shared(      int)[]));  // <- shared(const(int)[])
3831     static assert(is(typeof(f_w(swma1))  == shared(      int)[]));  // <- shared(inout(int))[]
3832     static assert(is(typeof(f_w(swma2))  == shared(      int)[]));  // <- shared(inout(int)[])
3833     static assert(is(typeof(f_w(swca1))  == shared(const int)[]));  // <- shared(inout(const(int)))[]
3834     static assert(is(typeof(f_w(swca2))  == shared(const int)[]));  // <- shared(inout(const(int))[])
3835     // 9 * 2 - 1
3836     static assert(is(typeof(fsw(  ma1))) == false);
3837     static assert(is(typeof(fsw(  ca1))) == false);
3838     static assert(is(typeof(fsw(  ca2))) == false);
3839     static assert(is(typeof(fsw( wma1))) == false);
3840     static assert(is(typeof(fsw( wma2))) == false);
3841     static assert(is(typeof(fsw( wca1))) == false);
3842     static assert(is(typeof(fsw( wca2))) == false);
3843     static assert(is(typeof(fsw(  ia1))  ==              int []));  // <- NG
3844     static assert(is(typeof(fsw(  ia2))  ==              int []));  // <- NG
3845     static assert(is(typeof(fsw( sma1))  ==              int []));  // <- NG
3846     static assert(is(typeof(fsw( sma2))  ==              int []));
3847     static assert(is(typeof(fsw( sca1))  ==              int []));  // <- NG
3848     static assert(is(typeof(fsw( sca2))  ==              int []));  // const(int)[]
3849     static assert(is(typeof(fsw(swma1))  ==              int []));  // <- NG
3850     static assert(is(typeof(fsw(swma2))  ==              int []));  // inout(int)[]
3851     static assert(is(typeof(fsw(swca1))  ==        const(int)[]));  // <- NG
3852     static assert(is(typeof(fsw(swca2))  ==        const(int)[]));  // <- inout(const(int))[]
3853 
3854     /* Parameter is (shared) inout const
3855      */
3856     U f_wc(U)(       inout const U) { return null; }
3857     U fswc(U)(shared inout const U) { return null; }
3858     // 9 * 2 - 1
3859     static assert(is(typeof(f_wc(  ma1))  ==        int []));
3860     static assert(is(typeof(f_wc(  ca1))  ==        int []));  // <- const(int)[]
3861     static assert(is(typeof(f_wc(  ca2))  ==        int []));  // <- const(int)[]
3862     static assert(is(typeof(f_wc( wma1))  ==        int []));  // <- inout(int)[]
3863     static assert(is(typeof(f_wc( wma2))  ==        int []));  // <- inout(int)[]
3864     static assert(is(typeof(f_wc( wca1))  ==        int []));  // <- inout(const(int))[]
3865     static assert(is(typeof(f_wc( wca2))  ==        int []));  // <- inout(const(int))[]
3866     static assert(is(typeof(f_wc(  ia1))  ==        int []));  // <- immutable(int)[]
3867     static assert(is(typeof(f_wc(  ia2))  ==        int []));  // <- immutable(int)[]
3868     static assert(is(typeof(f_wc( sma1))  == shared(int)[]));
3869     static assert(is(typeof(f_wc( sma2))  == shared(int)[]));  // <- shared(int[])
3870     static assert(is(typeof(f_wc( sca1))  == shared(int)[]));  // <- shared(const(int))[]
3871     static assert(is(typeof(f_wc( sca2))  == shared(int)[]));  // <- shared(const(int)[])
3872     static assert(is(typeof(f_wc(swma1))  == shared(int)[]));  // <- shared(inout(int))[]
3873     static assert(is(typeof(f_wc(swma2))  == shared(int)[]));  // <- shared(inout(int)[])
3874     static assert(is(typeof(f_wc(swca1))  == shared(int)[]));  // <- shared(inout(const(int)))[]
3875     static assert(is(typeof(f_wc(swca2))  == shared(int)[]));  // <- shared(inout(const(int))[])
3876     // 9 * 2 - 1
3877     static assert(is(typeof(fswc(  ma1))) == false);
3878     static assert(is(typeof(fswc(  ca1))) == false);
3879     static assert(is(typeof(fswc(  ca2))) == false);
3880     static assert(is(typeof(fswc( wma1))) == false);
3881     static assert(is(typeof(fswc( wma2))) == false);
3882     static assert(is(typeof(fswc( wca1))) == false);
3883     static assert(is(typeof(fswc( wca2))) == false);
3884     static assert(is(typeof(fswc(  ia1))  ==        int []));  // <- NG
3885     static assert(is(typeof(fswc(  ia2))  ==        int []));  // <- NG
3886     static assert(is(typeof(fswc( sma1))  ==        int []));  // <- NG
3887     static assert(is(typeof(fswc( sma2))  ==        int []));
3888     static assert(is(typeof(fswc( sca1))  ==        int []));  // <- NG
3889     static assert(is(typeof(fswc( sca2))  ==        int []));  // <- const(int)[]
3890     static assert(is(typeof(fswc(swma1))  ==        int []));  // <- NG
3891     static assert(is(typeof(fswc(swma2))  ==        int []));  // <- inout(int)[]
3892     static assert(is(typeof(fswc(swca1))  ==        int []));  // <- NG
3893     static assert(is(typeof(fswc(swca2))  ==        int []));  // <- inout(const(int))[]
3894 }+/
3895 
3896 void test13127a()
3897 {
3898     void foo(T)(in T[] src, T[] dst) { static assert(is(T == int[])); }
3899 
3900     int[][] a;
3901     foo(a, a);
3902 }
3903 
3904 /******************************************/
3905 // https://issues.dlang.org/show_bug.cgi?id=13159
3906 
3907 template maxSize13159(T...)
3908 {
3909     static if (T.length == 1)
3910     {
3911         enum size_t maxSize13159 = T[0].sizeof;
3912     }
3913     else
3914     {
3915         enum size_t maxSize13159 =
3916             T[0].sizeof >= maxSize13159!(T[1 .. $])
3917                 ? T[0].sizeof
3918                 : maxSize13159!(T[1 .. $]);
3919     }
3920 }
3921 
3922 struct Node13159
3923 {
3924     struct Pair
3925     {
3926         Node13159 value;
3927     }
3928 
3929     //alias Algebraic!(Node[], int) Value;
3930     enum n = maxSize13159!(Node13159[], int);
3931 }
3932 
3933 /******************************************/
3934 // https://issues.dlang.org/show_bug.cgi?id=13180
3935 
3936 void test13180()
3937 {
3938     inout(V) get1a(K, V)(inout(V[K]) aa, lazy inout(V) defaultValue)
3939     {
3940         static assert(is(V == string));
3941         static assert(is(K == string));
3942         return defaultValue;
3943     }
3944     inout(V) get1b(K, V)(lazy inout(V) defaultValue, inout(V[K]) aa)
3945     {
3946         static assert(is(V == string));
3947         static assert(is(K == string));
3948         return defaultValue;
3949     }
3950 
3951     inout(V) get2a(K, V)(inout(V)[K] aa, lazy inout(V) defaultValue)
3952     {
3953         static assert(is(V == string));
3954         static assert(is(K == string));
3955         return defaultValue;
3956     }
3957     inout(V) get2b(K, V)(lazy inout(V) defaultValue, inout(V)[K] aa)
3958     {
3959         static assert(is(V == string));
3960         static assert(is(K == string));
3961         return defaultValue;
3962     }
3963     string def;
3964     string[string] aa;
3965     string s1a = get1a(aa, def);
3966     string s1b = get1b(def, aa);
3967     string s2a = get2a(aa, def);
3968     string s2b = get2b(def, aa);
3969 }
3970 
3971 /******************************************/
3972 // https://issues.dlang.org/show_bug.cgi?id=13204
3973 
3974 struct A13204(uint v)
3975 {
3976     alias whatever = A13204y;
3977     static assert(is(whatever == A13204));
3978 }
3979 alias A13204x = A13204!1;
3980 alias A13204y = A13204x;
3981 
3982 struct B13204(uint v)
3983 {
3984     alias whatever = B13204z;
3985     static assert(is(whatever == B13204));
3986 }
3987 alias B13204x = B13204!1;
3988 alias B13204y = B13204x;
3989 alias B13204z = B13204y;
3990 
3991 void test13204()
3992 {
3993     static assert(is(A13204x == A13204!1));
3994     static assert(is(A13204x == A13204!1.whatever));
3995     static assert(is(A13204x == A13204y));
3996 
3997     static assert(is(B13204x == B13204!1));
3998     static assert(is(B13204x == B13204!1.whatever));
3999     static assert(is(B13204x == B13204y));
4000     static assert(is(B13204x == B13204z));
4001 }
4002 
4003 /******************************************/
4004 // https://issues.dlang.org/show_bug.cgi?id=8462 (dup of 13204)
4005 
4006 alias FP8462 = void function(C8462.Type arg);
4007 
4008 class C8462
4009 {
4010     enum Type { Foo }
4011     alias funcPtrPtr = FP8462*;
4012 }
4013 
4014 /******************************************/
4015 // https://issues.dlang.org/show_bug.cgi?id=13218
4016 
4017 template isCallable13218(T...)
4018     if (T.length == 1)
4019 {
4020     static assert(0);
4021 }
4022 
4023 template ParameterTypeTuple13218(func...)
4024     if (func.length == 1 && isCallable13218!func)
4025 {
4026     static assert(0);
4027 }
4028 
4029 struct R13218
4030 {
4031     private static string mangleFuncPtr(ArgTypes...)()
4032     {
4033         string result = "fnp_";
4034         foreach (T; ArgTypes)
4035             result ~= T.mangleof;
4036         return result;
4037     }
4038     void function(int) fnp_i;
4039     double delegate(double) fnp_d;
4040 
4041     void opAssign(FnT)(FnT func)
4042     {
4043         mixin(mangleFuncPtr!( ParameterTypeTuple13218!FnT) ~ " = func;");   // parsed as TypeInstance
4044       //mixin(mangleFuncPtr!(.ParameterTypeTuple13218!FnT) ~ " = func;");   // parsed as DotTemplateInstanceExp -> works
4045     }
4046 }
4047 
4048 /******************************************/
4049 // https://issues.dlang.org/show_bug.cgi?id=13219
4050 
4051 struct Map13219(V) {}
4052 
4053 void test13219a(alias F, VA, VB)(Map13219!VA a, Map13219!VB b)
4054 if (is(VA : typeof(F(VA.init, VB.init))))
4055 {}
4056 
4057 void test13219b(alias F)()
4058 {
4059     test13219a!((a, b) => b)(Map13219!int.init, Map13219!int.init);
4060 }
4061 
4062 void test13219()
4063 {
4064     int x;
4065     test13219b!x();
4066 }
4067 
4068 /******************************************/
4069 // https://issues.dlang.org/show_bug.cgi?id=13223
4070 
4071 void test13223()
4072 {
4073     T[] f1(T)(T[] a1, T[] a2)
4074     {
4075         static assert(is(T == int));
4076         return a1 ~ a2;
4077     }
4078     T[] f2(T)(T[] a1, T[] a2)
4079     {
4080         static assert(is(T == int));
4081         return a1 ~ a2;
4082     }
4083     int[] a = [1, 2];
4084     static assert(is(typeof(f1(a, [])) == int[]));
4085     static assert(is(typeof(f2([], a)) == int[]));
4086     static assert(is(typeof(f1(a, null)) == int[]));
4087     static assert(is(typeof(f2(null, a)) == int[]));
4088 
4089     T[] f3(T)(T[] a) { return a; }
4090     static assert(is(typeof(f3([])) == void[]));
4091     static assert(is(typeof(f3(null)) == void[]));
4092 
4093     T f4(T)(T a) { return a; }
4094     static assert(is(typeof(f4([])) == void[]));
4095     static assert(is(typeof(f4(null)) == typeof(null)));
4096 
4097     T[][] f5(T)(T[][] a) { return a; }
4098     static assert(is(typeof(f5([])) == void[][]));
4099     static assert(is(typeof(f5(null)) == void[][]));
4100 
4101     void translate(C = immutable char)(const(C)[] toRemove)
4102     {
4103         static assert(is(C == char));
4104     }
4105     translate(null);
4106 }
4107 
4108 void test13223a()
4109 {
4110     T f(T)(T, T) { return T.init; }
4111 
4112     immutable i = 0;
4113     const c = 0;
4114     auto m = 0;
4115     shared s = 0;
4116 
4117     static assert(is(typeof(f(i, i)) == immutable int));
4118     static assert(is(typeof(f(i, c)) ==     const int));
4119     static assert(is(typeof(f(c, i)) ==     const int));
4120     static assert(is(typeof(f(i, m)) ==           int));
4121     static assert(is(typeof(f(m, i)) ==           int));
4122     static assert(is(typeof(f(c, m)) ==           int));
4123     static assert(is(typeof(f(m, c)) ==           int));
4124     static assert(is(typeof(f(m, m)) ==           int));
4125     static assert(is(typeof(f(i, s)) ==    shared int));
4126     static assert(is(typeof(f(s, i)) ==    shared int));
4127     static assert(is(typeof(f(c, s)) ==    shared int));
4128     static assert(is(typeof(f(s, c)) ==    shared int));
4129     static assert(is(typeof(f(s, s)) ==    shared int));
4130     static assert(is(typeof(f(s, m)) ==           int));
4131     static assert(is(typeof(f(m, s)) ==           int));
4132 }
4133 
4134 /******************************************/
4135 // https://issues.dlang.org/show_bug.cgi?id=13235
4136 
4137 struct Tuple13235(T...)
4138 {
4139     T expand;
4140     alias expand field;
4141 
4142     this(T values)
4143     {
4144         field = values;
4145     }
4146 }
4147 struct Foo13235
4148 {
4149     Tuple13235!(int, Foo13235)* foo;
4150 }
4151 
4152 template Inst13235(T...)
4153 {
4154     struct Tuple
4155     {
4156         T expand;
4157         alias expand field;
4158 
4159         this(T values)
4160         {
4161             field = values;
4162         }
4163     }
4164     alias Inst13235 = Tuple*;
4165 }
4166 struct Bar13235
4167 {
4168     Inst13235!(int, Bar13235) bar;
4169 }
4170 
4171 void test13235()
4172 {
4173     alias Tup1 = Tuple13235!(int, Foo13235);
4174     assert(Tup1(1, Foo13235()).expand[0] == 1);
4175 
4176     alias Tup2 = typeof(*Inst13235!(int, Bar13235).init);
4177     assert(Tup2(1, Bar13235()).expand[0] == 1);
4178 }
4179 
4180 /******************************************/
4181 // https://issues.dlang.org/show_bug.cgi?id=13252
4182 
4183 alias TypeTuple13252(T...) = T;
4184 
4185 static assert(is(typeof(TypeTuple13252!(cast(int )1)[0]) == int ));
4186 static assert(is(typeof(TypeTuple13252!(cast(long)1)[0]) == long));
4187 
4188 static assert(is(typeof(TypeTuple13252!(cast(float )3.14)[0]) == float ));
4189 static assert(is(typeof(TypeTuple13252!(cast(double)3.14)[0]) == double));
4190 
4191 static assert(is(typeof(TypeTuple13252!(cast(cfloat )(1 + 2i))[0]) == cfloat ));
4192 static assert(is(typeof(TypeTuple13252!(cast(cdouble)(1 + 2i))[0]) == cdouble));
4193 
4194 static assert(is(typeof(TypeTuple13252!(cast(string  )null)[0]) == string  ));
4195 static assert(is(typeof(TypeTuple13252!(cast(string[])null)[0]) == string[]));  // OK <- NG
4196 
4197 static assert(is(typeof(TypeTuple13252!(cast(wstring)"abc")[0]) == wstring));
4198 static assert(is(typeof(TypeTuple13252!(cast(dstring)"abc")[0]) == dstring));
4199 
4200 static assert(is(typeof(TypeTuple13252!(cast(int[] )[])[0]) == int[] ));
4201 static assert(is(typeof(TypeTuple13252!(cast(long[])[])[0]) == long[]));        // OK <- NG
4202 
4203 struct S13252 { }
4204 static assert(is(typeof(TypeTuple13252!(const     S13252())[0]) ==     const(S13252)));
4205 static assert(is(typeof(TypeTuple13252!(immutable S13252())[0]) == immutable(S13252)));     // OK <- NG
4206 
4207 /******************************************/
4208 // https://issues.dlang.org/show_bug.cgi?id=13294
4209 
4210 void test13294()
4211 {
4212     void f(T)(const ref T src, ref T dst)
4213     {
4214         pragma(msg, "T = ", T);
4215         static assert(!is(T == const));
4216     }
4217     {
4218         const byte src;
4219               byte dst;
4220         f(src, dst);
4221     }
4222     {
4223         const char src;
4224               char dst;
4225         f(src, dst);
4226     }
4227 
4228     // https://issues.dlang.org/show_bug.cgi?id=13351
4229     T add(T)(in T x, in T y)
4230     {
4231         T z;
4232         z = x + y;
4233         return z;
4234     }
4235     const double a = 1.0;
4236     const double b = 2.0;
4237     double c;
4238     c = add(a,b);
4239 }
4240 
4241 /******************************************/
4242 // https://issues.dlang.org/show_bug.cgi?id=13299
4243 
4244 struct Foo13299
4245 {
4246     Foo13299 opDispatch(string name)(int a, int[] b...)
4247     if (name == "bar")
4248     {
4249         return Foo13299();
4250     }
4251 
4252     Foo13299 opDispatch(string name)()
4253     if (name != "bar")
4254     {
4255         return Foo13299();
4256     }
4257 }
4258 
4259 void test13299()
4260 {
4261     Foo13299()
4262         .bar(0)
4263         .bar(1)
4264         .bar(2);
4265 
4266     Foo13299()
4267         .opDispatch!"bar"(0)
4268         .opDispatch!"bar"(1)
4269         .opDispatch!"bar"(2);
4270 }
4271 
4272 /******************************************/
4273 // https://issues.dlang.org/show_bug.cgi?id=13333
4274 
4275 template AliasThisTypeOf13333(T)
4276 {
4277     static assert(0, T.stringof);  // T.stringof is important
4278 }
4279 
4280 template StaticArrayTypeOf13333(T)
4281 {
4282     static if (is(AliasThisTypeOf13333!T AT))
4283         alias X = StaticArrayTypeOf13333!AT;
4284     else
4285         alias X = T;
4286 
4287     static if (is(X : E[n], E, size_t n))
4288         alias StaticArrayTypeOf13333 = X;
4289     else
4290         static assert(0, T.stringof~" is not a static array type");
4291 }
4292 
4293 enum bool isStaticArray13333(T) = is(StaticArrayTypeOf13333!T);
4294 
4295 struct VaraiantN13333(T)
4296 {
4297     static if (isStaticArray13333!T)
4298         ~this() { static assert(0); }
4299 }
4300 
4301 struct DummyScope13333
4302 {
4303     alias A = VaraiantN13333!C;
4304 
4305     static class C
4306     {
4307         A entity;
4308     }
4309 }
4310 
4311 void test13333()
4312 {
4313     struct DummyScope
4314     {
4315         alias A = VaraiantN13333!C;
4316 
4317         static class C
4318         {
4319             A entity;
4320         }
4321     }
4322 }
4323 
4324 /******************************************/
4325 // https://issues.dlang.org/show_bug.cgi?id=13374
4326 
4327 int f13374(alias a)()  { return 1; }
4328 int f13374(string s)() { return 2; }
4329 
4330 void x13374(int i) {}
4331 
4332 void test13374()
4333 {
4334     assert(f13374!x13374() == 1);
4335 }
4336 
4337 /******************************************/
4338 // https://issues.dlang.org/show_bug.cgi?id=14109
4339 
4340 string f14109() { return "a"; }
4341 string g14109()() { return "a"; }
4342 
4343 struct S14109(string s) { static assert(s == "a"); }
4344 
4345 alias X14109 = S14109!(f14109);
4346 alias Y14109 = S14109!(g14109!());
4347 static assert(is(X14109 == Y14109));
4348 
4349 /******************************************/
4350 // https://issues.dlang.org/show_bug.cgi?id=13378
4351 
4352 struct Vec13378(size_t n, T, string as)
4353 {
4354     T[n] data;
4355 }
4356 
4357 void doSome13378(size_t n, T, string as)(Vec13378!(n,T,as) v) {}
4358 
4359 void test13378()
4360 {
4361     auto v = Vec13378!(3, float, "xyz")([1,2,3]);
4362     doSome13378(v);
4363 }
4364 
4365 /******************************************/
4366 // https://issues.dlang.org/show_bug.cgi?id=13379
4367 
4368 void test13379()
4369 {
4370     match13379("");
4371 }
4372 
4373 auto match13379(RegEx )(RegEx  re)
4374 if (is(RegEx == Regex13379!char))       // #1 Regex!char (speculative && tinst == NULL)
4375 {}
4376 auto match13379(String)(String re)
4377 {}
4378 
4379 struct Regex13379(Char)
4380 {
4381     ShiftOr13379!Char kickstart;        // #2 ShiftOr!char (speculative && tinst == Regex!char)
4382 }
4383 struct ShiftOr13379(Char)
4384 {
4385     this(ref Regex13379!Char re)        // #3 Regex!Char (speculative && tinst == ShiftOr!char)
4386     {
4387         uint n_length;
4388         uint idx;
4389         n_length = min13379(idx, n_length);
4390     }
4391 }
4392 
4393 template MinType13379(T...)
4394 {
4395     alias MinType13379 = T[0];
4396 }
4397 MinType13379!T min13379(T...)(T args)   // #4 MinType!uint (speculative && thist == ShiftOr!char)
4398 {
4399     alias a = args[0];
4400     alias b = args[$-1];
4401     return cast(typeof(return)) (a < b ? a : b);
4402 }
4403 
4404 /******************************************/
4405 // https://issues.dlang.org/show_bug.cgi?id=13417
4406 
4407 struct V13417(size_t N, E, alias string AS)
4408 {
4409 }
4410 
4411 auto f13417(E)(in V13417!(4, E, "ijka"))
4412 {
4413     return V13417!(3, E, "xyz")();
4414 }
4415 
4416 void test13417()
4417 {
4418     f13417(V13417!(4, float, "ijka")());
4419 }
4420 
4421 /******************************************/
4422 // https://issues.dlang.org/show_bug.cgi?id=13484
4423 
4424 int foo13484()(void delegate() hi) { return 1; }
4425 int foo13484(T)(void delegate(T) hi) { return 2; }
4426 
4427 void test13484()
4428 {
4429     assert(foo13484({}) == 1);          // works
4430     assert(foo13484((float v){}) == 2); // works <- throws error
4431 }
4432 
4433 /******************************************/
4434 // https://issues.dlang.org/show_bug.cgi?id=13675
4435 
4436 enum E13675;
4437 
4438 bool foo13675(T : E13675)()
4439 {
4440     return false;
4441 }
4442 
4443 void test13675()
4444 {
4445     if (foo13675!E13675)
4446     {}
4447 }
4448 
4449 /******************************************/
4450 // https://issues.dlang.org/show_bug.cgi?id=13694
4451 
4452 auto foo13694(T)(string A,         T[] G ...) { return 1; }
4453 auto foo13694(T)(string A, long E, T[] G ...) { return 2; }
4454 
4455 void test13694()
4456 {
4457     struct S {}
4458 
4459     S v;
4460     assert(foo13694("A", v) == 1);      // <- OK
4461     assert(foo13694("A", 0, v) == 2);   // <- used to be OK but now fails
4462     assert(foo13694!S("A", 0, v) == 2); // <- workaround solution
4463 }
4464 
4465 /******************************************/
4466 // https://issues.dlang.org/show_bug.cgi?id=13760
4467 
4468 void test13760()
4469 {
4470     void func(K, V)(inout(V[K]) aa, inout(V) val) {}
4471 
4472     class C {}
4473     C[int] aa;
4474     func(aa, new C);
4475 }
4476 
4477 /******************************************/
4478 // https://issues.dlang.org/show_bug.cgi?id=13714
4479 
4480 struct JSONValue13714
4481 {
4482     this(T)(T arg)
4483     {
4484     }
4485     this(T : JSONValue13714)(inout T arg) inout
4486     {
4487         //store = arg.store;
4488     }
4489 
4490     void opAssign(T)(T arg)
4491     {
4492     }
4493 }
4494 
4495 void test13714()
4496 {
4497     enum DummyStringEnum
4498     {
4499         foo = "bar"
4500     }
4501 
4502     JSONValue13714[string] aa;
4503     aa["A"] = DummyStringEnum.foo;
4504 }
4505 
4506 /******************************************/
4507 // https://issues.dlang.org/show_bug.cgi?id=13807
4508 
4509 T f13807(T)(inout(T)[] arr)
4510 {
4511     return T.init;
4512 }
4513 
4514 void test13807()
4515 {
4516     static assert(is(typeof(f13807([1, 2, 3])) == int));    // OK
4517     static assert(is(typeof(f13807(["a", "b"])) == string));    // OK <- Error
4518     static assert(is(typeof(f13807!string(["a", "b"])) == string)); // OK
4519 }
4520 
4521 /******************************************/
4522 // https://issues.dlang.org/show_bug.cgi?id=14174
4523 import imports.testmangle;
4524 
4525 struct Config14174(a, b) {}
4526 
4527 struct N14174 {}
4528 
4529 alias defConfig14174 = Config14174!(N14174, N14174);
4530 
4531 @safe @nogc pure nothrow
4532 void accepter14174a(Config : Config14174!(T) = defConfig14174, T...)()
4533 {
4534     static assert(equalDemangle(accepter14174a.mangleof,
4535            "_D7breaker131__T14"~
4536            "accepter14174a"~
4537            "HTS7breaker51__T11Config14174TS7breaker6N14174TS7breaker6N14174Z11Config14174TS7breaker6N14174TS7breaker6N14174Z14"~
4538            "accepter14174a"~
4539            "FNaNbNiNfZv"));
4540 }
4541 
4542 @safe @nogc pure nothrow
4543 void accepter14174b(Config : Config14174!(T) = defConfig14174, T...)()
4544 {
4545     static assert(equalDemangle(accepter14174b.mangleof,
4546            "_D7breaker131__T14"~
4547            "accepter14174b"~
4548            "HTS7breaker51__T11Config14174TS7breaker6N14174TS7breaker6N14174Z11Config14174TS7breaker6N14174TS7breaker6N14174Z14"~
4549            "accepter14174b"~
4550            "FNaNbNiNfZv"));
4551 }
4552 
4553 void test14174()
4554 {
4555     accepter14174a!()();
4556 
4557     accepter14174b!()();
4558 }
4559 
4560 /******************************************/
4561 // https://issues.dlang.org/show_bug.cgi?id=14836
4562 
4563 template a14836x(alias B, C...)
4564 {
4565     int a14836x(D...)()    if (D.length == 0) { return 1; }
4566     int a14836x(D...)(D d) if (D.length >  0) { return 2; }
4567 }
4568 template a14836y(alias B, C...)
4569 {
4570     int a14836y(T, D...)(T t)      if (D.length == 0) { return 1; }
4571     int a14836y(T, D...)(T t, D d) if (D.length >  0) { return 2; }
4572 }
4573 
4574 void test14836()
4575 {
4576     int v;
4577     assert(a14836x!(v)() == 1);
4578     assert(a14836x!(v)(1) == 2);
4579     assert(a14836y!(v)(1) == 1);
4580     assert(a14836y!(v)(1, 2) == 2);
4581 }
4582 
4583 /******************************************/
4584 // https://issues.dlang.org/show_bug.cgi?id=14357
4585 
4586 template Qux14357(T : U*, U : V*, V)
4587 {
4588     pragma(msg, T);     // no match <- float**
4589     pragma(msg, U);     // no match <- float*
4590     pragma(msg, V);     // no match <- int
4591     enum Qux14357 = T.sizeof + V.sizeof;
4592 }
4593 static assert(!__traits(compiles, Qux14357!(float**, int*)));
4594 
4595 /******************************************/
4596 // https://issues.dlang.org/show_bug.cgi?id=14481
4597 
4598 template someT14481(alias e)
4599 {
4600     alias someT14481 = e;
4601 }
4602 
4603 mixin template Mix14481(alias e)
4604 {
4605     alias SomeAlias = someT14481!e;
4606 }
4607 
4608 struct Hoge14481
4609 {
4610     mixin Mix14481!e;
4611     enum e = 10;
4612 }
4613 
4614 /******************************************/
4615 // https://issues.dlang.org/show_bug.cgi?id=14520
4616 
4617 template M14520(alias  a) { enum M14520 = 1; }
4618 template M14520(string s) { enum M14520 = 2; }
4619 
4620 int f14520a();
4621 string f14520b() { assert(0); }
4622 string f14520c() { return "a"; }
4623 
4624 static assert(M14520!f14520a == 1);
4625 static assert(M14520!f14520b == 1);
4626 static assert(M14520!f14520c == 1);
4627 
4628 /******************************************/
4629 // https://issues.dlang.org/show_bug.cgi?id=14568
4630 
4631 struct Interval14568()
4632 {
4633     auto left = INVALID;
4634 
4635     auto opAssign()(Interval14568) { left; }
4636 }
4637 
4638 auto interval14568(T)(T point)
4639 {
4640     Interval14568!();
4641 }
4642 
4643 alias Instantiate14568(alias symbol, Args...) = symbol!Args;
4644 
4645 template Match14568(patterns...)
4646 {
4647     static if (__traits(compiles, Instantiate14568!(patterns[0])))
4648     {
4649         alias Match14568 = patterns[0];
4650     }
4651     else static if (patterns.length == 1)
4652     {}
4653 }
4654 
4655 template SubOps14568(Args...)
4656 {
4657     auto opIndex()
4658     {
4659         template IntervalType(T...)
4660         {
4661             alias Point() = typeof(T.interval14568);
4662 
4663             alias IntervalType = Match14568!(Point);
4664         }
4665         alias Subspace = IntervalType!(Args);
4666     }
4667 }
4668 
4669 struct Nat14568 { mixin SubOps14568!(null); }
4670 
4671 /******************************************/
4672 // https://issues.dlang.org/show_bug.cgi?id=14603
4673 // https://issues.dlang.org/show_bug.cgi?id=14604
4674 
4675 struct S14603
4676 {
4677     template opDispatch(string name)
4678     {
4679         void opDispatch()() {}
4680     }
4681 }
4682 alias a14603 = S14603.opDispatch!"go";  // OK
4683 alias b14603 = S14603.go;               // OK <- NG
4684 
4685 struct S14604
4686 {
4687     template opDispatch(string name)
4688     {
4689         void opDispatch()() {}
4690     }
4691 }
4692 alias Id14604(alias thing) = thing;
4693 alias c14604 = Id14604!(S14604.opDispatch!"go");     // ok
4694 alias d14604 = Id14604!(S14604.go);                  // issue 14604, 'Error: template instance opDispatch!"go" cannot resolve forward reference'
4695 
4696 /******************************************/
4697 // https://issues.dlang.org/show_bug.cgi?id=14735
4698 
4699 enum CS14735 { yes, no }
4700 
4701 int indexOf14735a(Range      )(Range    s, in dchar c) { return 1; }
4702 int indexOf14735a(T, size_t n)(ref T[n] s, in dchar c) { return 2; }
4703 
4704 int indexOf14735b(Range      )(Range    s, in dchar c, in CS14735 cs = CS14735.yes) { return 1; }
4705 int indexOf14735b(T, size_t n)(ref T[n] s, in dchar c, in CS14735 cs = CS14735.yes) { return 2; }
4706 
4707 void test14735()
4708 {
4709     char[64] buf;
4710 
4711     // Supported from 2.063: (http://dlang.org/changelog#implicitarraycast)
4712     assert(indexOf14735a(buf[0..32], '\0') == 2);
4713     assert(indexOf14735b(buf[0..32], '\0') == 2);
4714 
4715     // Have to work as same as above.
4716     assert(indexOf14735a(buf[], '\0') == 2);
4717     assert(indexOf14735b(buf[], '\0') == 2);
4718 }
4719 
4720 /******************************************/
4721 // https://issues.dlang.org/show_bug.cgi?id=14743
4722 
4723 class A14743
4724 {
4725     auto func1 = (A14743 a) { a.func2!int(); };
4726     auto func2(T)() {}
4727 }
4728 
4729 /******************************************/
4730 // https://issues.dlang.org/show_bug.cgi?id=14802
4731 
4732 void test14802()
4733 {
4734     auto func(T)(T x, T y) { return x; }
4735 
4736     struct S1 { double x; alias x this; }
4737     struct S2 { double x; alias x this; }
4738     S1 s1;
4739     S2 s2;
4740 
4741     enum E1 : double { a = 1.0 }
4742     enum E2 : double { a = 1.0 }
4743 
4744     static assert(is(typeof( func(1 , 1 ) ) == int));
4745     static assert(is(typeof( func(1u, 1u) ) == uint));
4746     static assert(is(typeof( func(1u, 1 ) ) == uint));
4747     static assert(is(typeof( func(1 , 1u) ) == uint));
4748 
4749     static assert(is(typeof( func(1.0f, 1.0f) ) == float));
4750     static assert(is(typeof( func(1.0 , 1.0 ) ) == double));
4751     static assert(is(typeof( func(1.0 , 1.0f) ) == double));
4752     static assert(is(typeof( func(1.0f, 1.0 ) ) == double));
4753 
4754     static assert(is(typeof( func(s1, s1) ) == S1));
4755     static assert(is(typeof( func(s2, s2) ) == S2));
4756     static assert(is(typeof( func(s1, s2) ) == double));
4757     static assert(is(typeof( func(s2, s1) ) == double));
4758 
4759     static assert(is(typeof( func(E1.a, E1.a) ) == E1));
4760     static assert(is(typeof( func(E2.a, E2.a) ) == E2));
4761     static assert(is(typeof( func(E1.a, 1.0)  ) == double));
4762     static assert(is(typeof( func(E2.a, 1.0)  ) == double));
4763     static assert(is(typeof( func(1.0,  E1.a) ) == double));
4764     static assert(is(typeof( func(1.0,  E2.a) ) == double));
4765     static assert(is(typeof( func(E1.a, E2.a) ) == double));
4766     static assert(is(typeof( func(E2.a, E1.a) ) == double));
4767 }
4768 
4769 /******************************************/
4770 // https://issues.dlang.org/show_bug.cgi?id=14886
4771 
4772 void test14886()
4773 {
4774     alias R = int[100_000];
4775 
4776     auto front(T)(T[] a) {}
4777     front(R.init);
4778 
4779     auto bar1(T)(T, T[] a) { return T.init; }
4780     auto bar2(T)(T[] a, T) { return T.init; }
4781 
4782     static assert(is(typeof(bar1(1L, R.init)) == long));
4783     static assert(is(typeof(bar2(R.init, 1L)) == long));
4784     // <-- T should be deduced to int because R.init is rvalue...?
4785 
4786     ubyte x;
4787     static assert(is(typeof(bar1(x, R.init)) == int));
4788     static assert(is(typeof(bar2(R.init, x)) == int));
4789 }
4790 
4791 /******************************************/
4792 // https://issues.dlang.org/show_bug.cgi?id=15156
4793 
4794 // https://issues.dlang.org/show_bug.cgi?id=15156
4795 auto f15116a(T)(string s, string arg2) { return 1; }
4796 auto f15116b(T)(int    i, string arg2) { return 2; }
4797 
4798 template bish15116(T)
4799 {
4800     alias bish15116 = f15116a!T;
4801     alias bish15116 = f15116b!T;
4802 }
4803 
4804 void test15116()
4805 {
4806     alias func = bish15116!string;
4807     assert(func("", "") == 1);
4808     assert(func(12, "") == 2);
4809 }
4810 
4811 /******************************************/
4812 // https://issues.dlang.org/show_bug.cgi?id=15152
4813 
4814 void test15152()
4815 {
4816     void func(string M)() { }
4817 
4818     struct S
4819     {
4820         enum name = "a";
4821     }
4822 
4823     enum s = S.init;
4824     func!(s.name);
4825 }
4826 
4827 /******************************************/
4828 // https://issues.dlang.org/show_bug.cgi?id=15352
4829 
4830 struct S15352(T, T delegate(uint idx) supplier)
4831 {
4832 }
4833 
4834 auto make15352a(T, T delegate(uint idx) supplier)()
4835 {
4836     enum local = supplier;      // OK
4837     S15352!(T, local) ret;
4838     return ret;
4839 }
4840 
4841 auto make15352b(T, T delegate(uint idx) supplier)()
4842 {
4843     S15352!(T, supplier) ret;   // OK <- Error
4844     return ret;
4845 }
4846 
4847 void test15352()
4848 {
4849     enum dg = delegate(uint idx) => idx;
4850     auto s1 = S15352!(uint, dg)();
4851     auto s2 = make15352a!(uint, dg)();
4852     auto s3 = make15352b!(uint, dg)();
4853     assert(is(typeof(s1) == typeof(s2)));
4854     assert(is(typeof(s1) == typeof(s3)));
4855 }
4856 
4857 /******************************************/
4858 // https://issues.dlang.org/show_bug.cgi?id=15623
4859 
4860 struct WithFoo15623a { void foo() {} }
4861 struct WithFoo15623b { void foo() {} }
4862 struct WithFoo15623c { void foo() {} }
4863 struct WithFoo15623d { void foo() {} }
4864 
4865 struct WithoutFoo15623a {}
4866 struct WithoutFoo15623b {}
4867 struct WithoutFoo15623c {}
4868 struct WithoutFoo15623d {}
4869 
4870 struct CallsFoo15623(T)
4871 {
4872     T t;
4873     void bar() { t.foo(); }     // error occurs during TemplateInstance.semantic3
4874 }
4875 
4876 // Instantiations outside of function bodies
4877 static assert( is(CallsFoo15623!WithFoo15623a));
4878 static assert(!is(CallsFoo15623!WithoutFoo15623a));                     // OK <- NG
4879 static assert( __traits(compiles, CallsFoo15623!WithFoo15623b));
4880 static assert(!__traits(compiles, CallsFoo15623!WithoutFoo15623b));     // OK <- NG
4881 
4882 // Instantiations inside function bodies (OK)
4883 static assert( is(typeof({ alias Baz = CallsFoo15623!WithFoo15623c; return Baz.init; }())));
4884 static assert(!is(typeof({ alias Baz = CallsFoo15623!WithoutFoo15623c; return Baz.init; }())));
4885 static assert( __traits(compiles, { alias Baz = CallsFoo15623!WithFoo15623d; return Baz.init; }()));
4886 static assert(!__traits(compiles, { alias Baz = CallsFoo15623!WithoutFoo15623d; return Baz.init; }()));
4887 
4888 /******************************************/
4889 // https://issues.dlang.org/show_bug.cgi?id=15781
4890 
4891 void test15781()
4892 {
4893     static struct S
4894     {
4895         int value;
4896     }
4897 
4898     T foo(T)(T a, T b)
4899     {
4900         return T();
4901     }
4902 
4903     const S cs;
4904           S ms;
4905     static assert(is(typeof(foo(ms, ms)) ==       S));
4906     static assert(is(typeof(foo(ms, cs)) == const S));
4907     static assert(is(typeof(foo(cs, ms)) == const S));
4908     static assert(is(typeof(foo(cs, cs)) == const S));
4909 }
4910 
4911 /******************************************/
4912 // https://issues.dlang.org/show_bug.cgi?id=16042
4913 
4914 struct Foo16042 {}
4915 
4916 auto map16042(alias func, T)(T t)
4917 {
4918     return func(t);
4919 }
4920 
4921 auto toChars16042(R)(R r) if (is(R == int[]))
4922 {
4923     Foo16042 f;
4924     assert(toChars16042(f) == 1);               // OK
4925     assert(map16042!(toChars16042)(f) == 1);    // OK <- NG
4926     assert(map16042!((toChars16042))(f) == 1);  // OK
4927 }
4928 
4929 auto toChars16042(Foo16042 f)
4930 {
4931     return 1;
4932 }
4933 
4934 void test16042()
4935 {
4936     [1].toChars16042();
4937 }
4938 
4939 // ---
4940 
4941 auto fn16042(R)(R r) if (is(R == int[])) {}
4942 auto fn16042(Foo16042 f) { return 1; }
4943 
4944 struct Namespace16042
4945 {
4946     alias fn = fn16042!(int[]);
4947 }
4948 
4949 void test16042b()
4950 {
4951     Foo16042 f;
4952 
4953     with (Namespace16042)
4954     {
4955         static assert(!__traits(compiles, fn(f)));              // NG
4956         static assert(!__traits(compiles, map16042!(fn)(f)));   // should be NG -> actually NG
4957         static assert(!__traits(compiles, map16042!((fn))(f))); // NG
4958     }
4959 }
4960 
4961 /******************************************/
4962 // https://issues.dlang.org/show_bug.cgi?id=15243
4963 
4964 struct S15243(Types...)
4965 {
4966     void apply1(U)(U delegate(Types[0]) f0) {}
4967 
4968     void apply2(U)(U delegate(Types) f0) {}
4969 
4970     void apply3(U)(U delegate(Types[1..$]) f0) {}
4971 }
4972 
4973 void test15243()
4974 {
4975     int f1(int) { return 0; }
4976     int f2(int, long) { return 0; }
4977     int f3(long, string) { return 0; }
4978 
4979     S15243!(int) s1;
4980     s1.apply1(&f1);
4981     s1.apply2(&f1);
4982 
4983     S15243!(int, long) s2;
4984     s2.apply2(&f2);
4985 
4986     S15243!(int, long, string) s3;
4987     s3.apply3(&f3);
4988 }
4989 
4990 /******************************************/
4991 // https://issues.dlang.org/show_bug.cgi?id=15653
4992 
4993 alias TypeTuple15653(T...) = T;
4994 
4995 void test15653()
4996 {
4997     void foo(U, T)(const T x)     { static assert(is(T == U)); }
4998     void bar(U, T)(immutable T x) { static assert(is(T == U)); }
4999 
5000     struct X { int a; long[2] b; }
5001     struct Y { int* a; long[] b; }
5002 
5003     foreach (U; TypeTuple15653!( byte,    short,   int,  long,
5004                                 ubyte,   ushort,  uint, ulong,
5005                                  float,  double,  real,
5006                                 ifloat, idouble, ireal,
5007                                 cfloat, cdouble, creal,
5008                                 void delegate(),
5009                                 int[2], X, X[2]))
5010     {
5011         foo!U(U.init);      // OK
5012         bar!U(U.init);      // Was error, now OK
5013 
5014         U u;
5015         foo!U(u);           // OK
5016         bar!U(u);           // Was error, now OK
5017     }
5018 
5019     foreach (U; TypeTuple15653!(void*, int**, long[], double*[2]))
5020     {
5021         foo!U(U.init);      // OK
5022         bar!U(U.init);      // Was error, now OK
5023 
5024         U u;
5025         foo!U(u);
5026         static assert(!__traits(compiles, bar!U(u)), U.stringof);
5027     }
5028 
5029     foreach (U; TypeTuple15653!(Object, Y, Y[2], int[int]))
5030     {
5031         foo!U(U.init);      // OK
5032         static assert(!__traits(compiles, bar!U(U.init)), U.stringof);
5033 
5034         U u;
5035         foo!U(u);           // OK
5036         static assert(!__traits(compiles, bar!U(u)), U.stringof);
5037     }
5038 }
5039 
5040 /******************************************/
5041 
5042 int main()
5043 {
5044     test1();
5045     test2();
5046     test3();
5047     test4();
5048     test5();
5049     test6();
5050     test7();
5051     test8();
5052     test9();
5053     test1780();
5054     test3608();
5055     test5893();
5056     test6404();
5057     test2246();
5058     test2296();
5059     bug4984();
5060     test2579();
5061     test2803();
5062     test6613();
5063     test5886();
5064     test5393();
5065     test5896();
5066     test6825();
5067     test6789();
5068     test2778();
5069     test2778aa();
5070     test2778get();
5071     test6208a();
5072     test6208b();
5073     test6208c();
5074     test6738();
5075     test6780();
5076     test6810();
5077     test6891();
5078     test6994();
5079     test6764();
5080     test3467();
5081     test4413();
5082     test5525();
5083     test5801();
5084     test10();
5085     test7037();
5086     test7124();
5087     test7359();
5088     test7416();
5089     test7563();
5090     test7572();
5091     test7580();
5092     test7585();
5093     test7671();
5094     test7672();
5095     test7684();
5096     test11a();
5097     test11b();
5098     test7769();
5099     test7873();
5100     test7933();
5101     test8094();
5102     test12();
5103     test8125();
5104     test13();
5105     test14();
5106     test8129();
5107     test8238();
5108     test8669();
5109     test8833();
5110     test8976();
5111     test8940();
5112     test9022();
5113     test9026();
5114     test9038();
5115     test9076();
5116     test9100();
5117     test9124a();
5118     test9124b();
5119     test9143();
5120     test9266();
5121     test9536();
5122     test9578();
5123     test9596();
5124     test9837();
5125     test9874();
5126     test9885();
5127     test9971();
5128     test9977();
5129     test10083();
5130     test10592();
5131     test11242();
5132     test10811();
5133     test10969();
5134     test11271();
5135     test11533();
5136     test11818();
5137     test11843();
5138     test11872();
5139     test12122();
5140     test12207();
5141     test12376();
5142     test13235();
5143     test13294();
5144     test13299();
5145     test13374();
5146     test13378();
5147     test13379();
5148     test13484();
5149     test13694();
5150     test14836();
5151     test14735();
5152     test14802();
5153     test15116();
5154     test16042();
5155     test16042b();
5156     test15243();
5157     test15653();
5158 
5159     printf("Success\n");
5160     return 0;
5161 }