1 // REQUIRED_ARGS: -preview=rvaluerefparam
2 //
3 /* TEST_OUTPUT:
4 ---
5 Boo!double
6 Boo!int
7 true
8 int
9 !! immutable(int)[]
10 int(int i, long j = 7L)
11 long
12 C10390(C10390(C10390(<recursion>)))
13 tuple(height)
14 tuple(get, get)
15 tuple(clear)
16 tuple(draw, draw)
17 runnable/xtest46.d(149): Deprecation: `opDot` is deprecated. Use `alias this`
18 runnable/xtest46.d(151): Deprecation: `opDot` is deprecated. Use `alias this`
19 runnable/xtest46.d(152): Deprecation: `opDot` is deprecated. Use `alias this`
20 runnable/xtest46.d(154): Deprecation: `opDot` is deprecated. Use `alias this`
21 runnable/xtest46.d(181): Deprecation: `opDot` is deprecated. Use `alias this`
22 runnable/xtest46.d(183): Deprecation: `opDot` is deprecated. Use `alias this`
23 runnable/xtest46.d(184): Deprecation: `opDot` is deprecated. Use `alias this`
24 runnable/xtest46.d(186): Deprecation: `opDot` is deprecated. Use `alias this`
25 const(int)
26 string[]
27 double[]
28 double[]
29 {}
30 tuple("m")
31 true
32 TFunction1: extern (C) void function()
33 ---
34 */
35 
36 //import std.stdio;
37 import core.stdc.stdio;
38 
39 /******************************************/
40 
41 struct S
42 {
43     int opUnary(string op)() if (op == "*") { return 7; }
44 }
45 
test1()46 void test1()
47 {
48     S s;
49 
50     printf("%d\n", *s);
51     assert(*s == 7);
52 }
53 
54 /******************************************/
55 
test2()56 void test2()
57 {
58   double[1][2] bar;
59   bar[0][0] = 1.0;
60   bar[1][0] = 2.0;
61   foo2(bar);
62 }
63 
foo2(T...)64 void foo2(T...)(T args)
65 {
66     foreach (arg; args[0 .. $])
67     {
68         //writeln(arg);
69         bar2!(typeof(arg))(&arg);
70     }
71 }
72 
73 
bar2(D)74 void bar2(D)(const(void)* arg)
75 {
76     D obj = *cast(D*) arg;
77 }
78 
79 
80 /***************************************************/
81 
test4()82 void test4()
83 {
84   immutable int maxi = 8;
85   int[][maxi] neighbors = [ cast(int[])[ ], [ 0 ], [ 0, 1], [ 0, 2], [1, 2], [1, 2, 3, 4],
86 [ 2, 3, 5], [ 4, 5, 6 ] ];
87   int[maxi] grid;
88 
89   // neighbors[0].length = 0;
90 
91   void place(int k, uint mask)
92   { if(k<maxi) {
93       for(uint m = 1, d = 1; d <= maxi; d++, m<<=1)
94         if(!(mask & m)) {
95           bool ok = true;
96           int dif;
97           foreach(nb; neighbors[k])
98             if((dif=grid[nb]-d)==1 || dif==-1) {
99               ok = false; break;
100             }
101           if(ok) {
102             grid[k] = d;
103             place(k+1, mask | m);
104           }
105         }
106     } else {
107       printf("  %d\n%d %d %d\n%d %d %d\n  %d\n\n",
108              grid[0], grid[1], grid[2], grid[3], grid[4], grid[5], grid[6], grid[7]);
109     }
110   }
111   place(0, 0);
112 }
113 
114 
115 /***************************************************/
116 
117 struct S5
118 {
119   enum S5 some_constant = {2};
120 
121   int member;
122 }
123 
test5()124 void test5()
125 {
126 }
127 
128 /***************************************************/
129 
130 struct S6
131 {
132     int a, b, c;
133 }
134 
135 struct T6
136 {
137     S6 s;
138     int b = 7;
139 
140     S6* opDot() return
141     {
142         return &s;
143     }
144 }
145 
146 void test6()
147 {
148     T6 t;
149     t.a = 4;
150     t.b = 5;
151     t.c = 6;
152     assert(t.a == 4);
153     assert(t.b == 5);
154     assert(t.c == 6);
155     assert(t.s.b == 0);
156     assert(t.sizeof == 4*4);
157     assert(t.init.sizeof == 4*4);
158 }
159 
160 /***************************************************/
161 
162 struct S7
163 {
164     int a, b, c;
165 }
166 
167 class C7
168 {
169     S7 s;
170     int b = 7;
171 
172     S7* opDot()
173     {
174         return &s;
175     }
176 }
177 
178 void test7()
179 {
180     C7 t = new C7();
181     t.a = 4;
182     t.b = 5;
183     t.c = 6;
184     assert(t.a == 4);
185     assert(t.b == 5);
186     assert(t.c == 6);
187     assert(t.s.b == 0);
188     assert(t.sizeof == (void*).sizeof);
189     assert(t.init is null);
190 }
191 
192 /***************************************************/
193 
194 void foo8(int n1 = __LINE__ + 0, int n2 = __LINE__, string s = __FILE__)
195 {
196     assert(n1 < n2);
197     printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, cast(int)s.length, s.ptr);
198 }
199 
200 void test8()
201 {
202     foo8();
203 }
204 
205 /***************************************************/
206 
207 void foo9(int n1 = __LINE__ + 0, int n2 = __LINE__, string s = __FILE__)()
208 {
209     assert(n1 < n2);
210     printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, cast(int)s.length, s.ptr);
211 }
212 
213 void test9()
214 {
215     foo9();
216 }
217 
218 /***************************************************/
219 
220 int foo10(char c) pure nothrow
221 {
222     return 1;
223 }
224 
225 void test10()
226 {
227     int function(char c) fp;
228     int function(char c) pure nothrow fq;
229 
230     fp = &foo10;
231     fq = &foo10;
232 }
233 
234 /***************************************************/
235 
236 class Base11 {}
237 class Derived11 : Base11 {}
238 class MoreDerived11 : Derived11 {}
239 
240 int fun11(Base11) { return 1; }
241 int fun11(Derived11) { return 2; }
242 
243 void test11()
244 {
245     MoreDerived11 m;
246 
247     auto i = fun11(m);
248     assert(i == 2);
249 }
250 
251 /***************************************************/
252 
253 interface ABC {};
254 interface AB: ABC {};
255 interface BC: ABC {};
256 interface AC: ABC {};
257 interface A: AB, AC {};
258 interface B: AB, BC {};
259 interface C: AC, BC {};
260 
261 int f12(AB ab) { return 1; }
262 int f12(ABC abc) { return 2; }
263 
264 void test12()
265 {
266     A a;
267     auto i = f12(a);
268     assert(i == 1);
269 }
270 
271 /***************************************************/
272 
273 template Foo13(alias x)
274 {
275     enum bar = x + 1;
276 }
277 
278 static assert(Foo13!(2+1).bar == 4);
279 
280 template Bar13(alias x)
281 {
282     enum bar = x;
283 }
284 
285 static assert(Bar13!("abc").bar == "abc");
286 
287 void test13()
288 {
289 }
290 
291 /***************************************************/
292 
293 template Foo14(alias a)
294 {
295     alias Bar14!(a) Foo14;
296 }
297 
298 int Bar14(alias a)()
299 {
300     return a.sizeof;
301 }
302 
303 void test14()
304 {
305     auto i = Foo14!("hello")();
306     printf("i = %d\n", i);
307     assert(i == "hello".sizeof);
308     i = Foo14!(1)();
309     printf("i = %d\n", i);
310     assert(i == 4);
311 }
312 
313 /***************************************************/
314 
315 auto foo15()(int x)
316 {
317     return 3 + x;
318 }
319 
320 void test15()
321 {
322 
323     auto bar()(int x)
324     {
325         return 5 + x;
326     }
327 
328     printf("%d\n", foo15(4));
329     printf("%d\n", bar(4));
330 }
331 
332 /***************************************************/
333 
334 int foo16(int x) { return 1; }
335 int foo16(ref int x) { return 2; }
336 
337 void test16()
338 {
339     int y;
340     auto i = foo16(y);
341     printf("i == %d\n", i);
342     assert(i == 2);
343     i = foo16(3);
344     assert(i == 1);
345 }
346 
347 /***************************************************/
348 
349 class A17 { }
350 class B17 : A17 { }
351 class C17 : B17 { }
352 
353 int foo17(A17, ref int x) { return 1; }
354 int foo17(B17, ref int x) { return 2; }
355 
356 void test17()
357 {
358     C17 c;
359     int y;
360     auto i = foo17(c, y);
361     printf("i == %d\n", i);
362     assert(i == 2);
363 }
364 
365 /***************************************************/
366 
367 class C18
368 {
369     void foo(int x) { foo("abc"); }
370     void foo(string s) { }  // this is hidden, but that's ok 'cuz no overlap
371     void bar()
372     {
373         foo("abc");
374     }
375 }
376 
377 class D18 : C18
378 {
379     override void foo(int x) { }
380 }
381 
382 void test18()
383 {
384     D18 d = new D18();
385     d.bar();
386 }
387 
388 /***************************************************/
389 
390 int foo19(alias int a)() { return a; }
391 
392 void test19()
393 {
394     int y = 7;
395     auto i = foo19!(y)();
396     printf("i == %d\n", i);
397     assert(i == 7);
398 
399     i = foo19!(4)();
400     printf("i == %d\n", i);
401     assert(i == 4);
402 }
403 
404 /***************************************************/
405 
406 template Foo20(int x) if (x & 1)
407 {
408     const int Foo20 = 6;
409 }
410 
411 template Foo20(int x) if ((x & 1) == 0)
412 {
413     const int Foo20 = 7;
414 }
415 
416 void test20()
417 {
418     int i = Foo20!(3);
419     printf("%d\n", i);
420     assert(i == 6);
421     i = Foo20!(4);
422     printf("%d\n", i);
423     assert(i == 7);
424 }
425 
426 /***************************************************/
427 
428 template isArray21(T : U[], U)
429 {
430   static const isArray21 = 1;
431 }
432 
433 template isArray21(T)
434 {
435   static const isArray21 = 0;
436 }
437 
438 int foo21(T)(T x) if (isArray21!(T))
439 {
440     return 1;
441 }
442 
443 int foo21(T)(T x) if (!isArray21!(T))
444 {
445     return 2;
446 }
447 
448 void test21()
449 {
450     auto i = foo21(5);
451     assert(i == 2);
452     int[] a;
453     i = foo21(a);
454     assert(i == 1);
455 }
456 
457 /***************************************************/
458 
459 void test22()
460 {
461     immutable uint x, y;
462     foreach (i; x .. y) {}
463 }
464 
465 /***************************************************/
466 
467 const bool foo23 = is(typeof(function void() { }));
468 const bar23      = is(typeof(function void() { }));
469 
470 void test23()
471 {
472     assert(foo23 == true);
473     assert(bar23 == true);
474 }
475 
476 /***************************************************/
477 
478 ref int foo24(int i)
479 {
480     static int x;
481     x = i;
482     return x;
483 }
484 
485 void test24()
486 {
487     int x = foo24(3);
488     assert(x == 3);
489 }
490 
491 /***************************************************/
492 
493 ref int foo25(int i)
494 {
495     static int x;
496     x = i;
497     return x;
498 }
499 
500 int bar25(ref int x)
501 {
502     return x + 1;
503 }
504 
505 void test25()
506 {
507     int x = bar25(foo25(3));
508     assert(x == 4);
509 }
510 
511 /***************************************************/
512 
513 static int x26;
514 
515 ref int foo26(int i)
516 {
517     x26 = i;
518     return x26;
519 }
520 
521 void test26()
522 {
523     int* p = &foo26(3);
524     assert(*p == 3);
525 }
526 
527 /***************************************************/
528 
529 static int x27 = 3;
530 
531 ref int foo27(int i)
532 {
533     return x27;
534 }
535 
536 void test27()
537 {
538     foo27(3) = 4;
539     assert(x27 == 4);
540 }
541 
542 /***************************************************/
543 
544 ref int foo28(return ref int x) { return x; }
545 
546 void test28()
547 {
548     int a;
549     foo28(a);
550 }
551 
552 /***************************************************/
553 
554 void wyda(int[] a) { printf("aaa\n"); }
555 void wyda(int[int] a) { printf("bbb\n"); }
556 
557 struct S29
558 {
559     int[] a;
560 
561     void wyda()
562     {
563         a.wyda;
564         a.wyda();
565     }
566 }
567 
568 void test29()
569 {
570     int[] a;
571     a.wyda;
572     int[5] b;
573     b.wyda;
574     int[int] c;
575     c.wyda;
576 
577     S29 s;
578     s.wyda();
579 }
580 
581 /***************************************************/
582 
583 void foo30(D)(D arg) if (isIntegral!D)
584 {
585 }
586 
587 struct S30(T) { }
588 struct U30(int T) { }
589 
590 alias int myint30;
591 
592 void test30()
593 {
594 
595     S30!myint30 u;
596     S30!int s;
597     S30!(int) t = s;
598 
599 //    U30!3 v = s;
600 }
601 
602 /***************************************************/
603 
604 class A31
605 {
606     void foo(int* p) { }
607 }
608 
609 class B31 : A31
610 {
611     override void foo(scope int* p) { }
612 }
613 
614 void test31()
615 {
616 }
617 
618 /***************************************************/
619 
620 void bar32() { }
621 
622 nothrow void foo32(int* p)
623 {
624     //try { bar32(); } catch (Object o) { }
625     try { bar32(); } catch (Throwable o) { }
626     try { bar32(); } catch (Exception o) { }
627 }
628 
629 void test32()
630 {   int i;
631 
632     foo32(&i);
633 }
634 
635 /***************************************************/
636 
637 struct Integer
638 {
639     this(int i)
640     {
641         this.i = i;
642     }
643 
644     this(long ii)
645     {
646       i = 3;
647     }
648 
649     const int i;
650 }
651 
652 void test33()
653 {
654 }
655 
656 /***************************************************/
657 
658 void test34()
659 {
660   alias uint Uint;
661   foreach(Uint u;1..10) {}
662   for(Uint u=1;u<10;u++) {}
663 }
664 
665 /***************************************************/
666 
667 ref int foo35(bool condition, return ref int lhs, return ref int rhs)
668 {
669         if ( condition ) return lhs;
670         return rhs;
671 }
672 
673 ref int bar35()(bool condition, return ref int lhs, return ref int rhs)
674 {
675         if ( condition ) return lhs;
676         return rhs;
677 }
678 
679 void test35()
680 {
681         int a = 10, b = 11;
682 
683         foo35(a<b, a, b) = 42;
684         printf("a = %d and b = %d\n", a, b); // a = 42 and b = 11
685         assert(a == 42 && b == 11);
686 
687         bar35(a<b, a, b) = 52;
688         printf("a = %d and b = %d\n", a, b);
689         assert(a == 42 && b == 52);
690 }
691 
692 /***************************************************/
693 
694 int foo36(T...)(T ts)
695 if (T.length > 1)
696 {
697     return T.length;
698 }
699 
700 int foo36(T...)(T ts)
701 if (T.length <= 1)
702 {
703     return T.length * 7;
704 }
705 
706 void test36()
707 {
708     auto i = foo36!(int,int)(1, 2);
709     assert(i == 2);
710     i = foo36(1, 2, 3);
711     assert(i == 3);
712     i = foo36(1);
713     assert(i == 7);
714     i = foo36();
715     assert(i == 0);
716 }
717 
718 
719 /***************************************************/
720 
721 void test6685()
722 {
723     struct S { int x; }
724     with({ return S(); }())
725     {
726         x++;
727     }
728 }
729 
730 /***************************************************/
731 
732 struct A37(alias T)
733 {
734 }
735 
736 void foo37(X)(X x) if (is(X Y == A37!(U), alias U))
737 {
738 }
739 
740 void bar37() {}
741 
742 void test37()
743 {
744     A37!(bar37) a2;
745     foo37(a2);
746     foo37!(A37!bar37)(a2);
747 }
748 
749 /***************************************************/
750 
751 struct A38
752 {
753     this(this)
754     {
755         printf("B's copy\n");
756     }
757     bool empty() {return false;}
758     void popFront() {}
759     int front() { return 1; }
760 //    ref A38 opSlice() { return this; }
761 }
762 
763 void test38()
764 {
765     A38 a;
766     int i;
767     foreach (e; a) { if (++i == 100) break; }
768 }
769 
770 /***************************************************/
771 
772 alias int function() Fun39;
773 alias ref int function() Gun39;
774 static assert(!is(Fun39 == Gun39));
775 
776 void test39()
777 {
778 }
779 
780 /***************************************************/
781 
782 int x40;
783 
784 struct Proxy
785 {
786     ref int at(int i)() { return x40; }
787 }
788 
789 void test40()
790 {
791     Proxy p;
792     auto x = p.at!(1);
793 }
794 
795 /***************************************************/
796 
797 template Foo41(TList...)
798 {
799     alias TList Foo41;
800 }
801 
802 alias Foo41!(immutable(ubyte)[], ubyte[]) X41;
803 
804 void test41()
805 {
806 }
807 
808 
809 /***************************************************/
810 
811 bool endsWith(A1, A2)(A1 longer, A2 shorter)
812 {
813     static if (is(typeof(longer[0 .. 0] == shorter)))
814     {
815     }
816     else
817     {
818     }
819     return false;
820 }
821 
822 void test42()
823 {
824     char[] a;
825     byte[] b;
826     endsWith(a, b);
827 }
828 
829 /***************************************************/
830 
831 void f43(S...)(S s) if (S.length > 3)
832 {
833 }
834 
835 void test43()
836 {
837     f43(1, 2, 3, 4);
838 }
839 
840 
841 /***************************************************/
842 
843 struct S44(int x = 1){}
844 
845 void fun()(S44!(1) b) { }
846 
847 void test44()
848 {
849     S44!() s;
850     fun(s);
851 }
852 
853 /***************************************************/
854 // https://issues.dlang.org/show_bug.cgi?id=2006
855 
856 void test2006()
857 {
858     string [][] aas = [];
859     assert(aas.length == 0);
860     aas ~= cast (string []) [];
861     assert(aas.length == 1);
862     aas = aas ~ cast (string []) [];
863     assert(aas.length == 2);
864 }
865 
866 /***************************************************/
867 // https://issues.dlang.org/show_bug.cgi?id=8442
868 
869 void test8442()
870 {
871     enum int[] fooEnum = [];
872     immutable fooImmutable = fooEnum;
873 }
874 
875 /***************************************************/
876 
877 class A45
878 {
879   int x;
880   int f()
881   {
882     printf("A\n");
883     return 1;
884   }
885 }
886 
887 class B45 : A45
888 {
889   override const int f()
890   {
891     printf("B\n");
892     return 2;
893   }
894 }
895 
896 void test45()
897 {
898     A45 y = new B45;
899     int i = y.f;
900     assert(i == 2);
901 }
902 
903 /***************************************************/
904 
905 void text10682()
906 {
907     ulong x = 1;
908     ulong y = 2 ^^ x;
909 }
910 
911 /***************************************************/
912 
913 struct Test46
914 {
915  int foo;
916 }
917 
918 void test46()
919 {
920     enum Test46 test = {};
921     enum q = test.foo;
922 }
923 
924 /***************************************************/
925 
926 pure int double_sqr(int x) {
927     int y = x;
928     void do_sqr() { y *= y; }
929     do_sqr();
930     return y;
931 }
932 
933 void test47()
934 {
935    assert(double_sqr(10) == 100);
936 }
937 
938 /***************************************************/
939 
940 void sort(alias less)(string[] r)
941 {
942             bool pred()
943             {
944                 return less("a", "a");
945             }
946             .sort!(less)(r);
947 }
948 
949 void foo48()
950 {
951     int[string] freqs;
952     string[] words;
953 
954 sort!((a, b) { return freqs[a] > freqs[b]; })(words);
955 sort!((string a, string b) { return freqs[a] > freqs[b]; })(words);
956 //sort!(bool (a, b) { return freqs[a] > freqs[b]; })(words);
957 //sort!(function (a, b) { return freqs[a] > freqs[b]; })(words);
958 //sort!(function bool(a, b) { return freqs[a] > freqs[b]; })(words);
959 sort!(delegate bool(string a, string b) { return freqs[a] > freqs[b]; })(words);
960 
961 }
962 
963 void test48()
964 {
965 }
966 
967 /***************************************************/
968 // https://issues.dlang.org/show_bug.cgi?id=6408
969 
970 static assert(!is(typeof(string[0..1].init)));
971 static assert(is(typeof(string[].init) == string[]));
972 static assert(is(typeof(string[][].init) == string[][]));
973 static assert(is(typeof(string[][][].init) == string[][][]));
974 
975 static assert(is(typeof(string[1].init) == string[1]));
976 static assert(is(typeof(string[1][1].init) == string[1][1]));
977 static assert(is(typeof(string[1][1][1].init) == string[1][1][1]));
978 
979 static assert(is(typeof(string[string].init) == string[string]));
980 static assert(is(typeof(string[string][string].init) == string[string][string]));
981 static assert(is(typeof(string[string][string][string].init) == string[string][string][string]));
982 
983 template TT6408(T...) { alias T TT6408; }
984 static assert(is(typeof(TT6408!(int, int)[].init) == TT6408!(int, int)));
985 static assert(is(typeof(TT6408!(int, int)[0..$].init) == TT6408!(int, int)));
986 static assert(is(typeof(TT6408!(int, int)[$-1].init) == int));
987 
988 /***************************************************/
989 // https://issues.dlang.org/show_bug.cgi?id=9409
990 
991 template TT9409(T...) { alias T TT9409; }
992 
993 template idxTypes9409(Prefix...)
994 {
995     TT9409!((Prefix[$-1])) idxTypes9409;
996 }
997 
998 alias idxTypes9409!(int) Types9409;
999 
1000 /***************************************************/
1001 
1002 struct S49
1003 {
1004     static void* p;
1005 
1006     this( string name )
1007     {
1008         printf( "(ctor) &%.*s.x = %p\n", cast(int)name.length, name.ptr, &x );
1009         p = cast(void*)&x;
1010     }
1011 
1012     invariant() {}
1013 
1014     int x;
1015 }
1016 
1017 void test49()
1018 {
1019     auto s = new S49("s2");
1020 
1021     printf( "&s2.x = %p\n", &s.x );
1022     assert(cast(void*)&s.x == S49.p);
1023 }
1024 
1025 /***************************************************/
1026 
1027 auto max50(Ts...)(Ts args)
1028   if (Ts.length >= 2
1029         && is(typeof(Ts[0].init > Ts[1].init ? Ts[1].init : Ts[0].init)))
1030 {
1031     static if (Ts.length == 2)
1032         return args[1] > args[0] ? args[1] : args[0];
1033     else
1034         return max50(max50(args[0], args[1]), args[2 .. $]);
1035 }
1036 
1037 void test50()
1038 {
1039    assert(max50(4, 5) == 5);
1040    assert(max50(2.2, 4.5) == 4.5);
1041    assert(max50("Little", "Big") == "Little");
1042 
1043    assert(max50(4, 5.5) == 5.5);
1044    assert(max50(5.5, 4) == 5.5);
1045 }
1046 
1047 /***************************************************/
1048 
1049 void test51()
1050 {
1051     static immutable int[2] array = [ 42 ];
1052     enum e = array[1];
1053     static immutable int[1] array2 = [ 0: 42 ];
1054     enum e2 = array2[0];
1055     assert(e == 0);
1056     assert(e2 == 42);
1057 }
1058 
1059 /***************************************************/
1060 
1061 enum ubyte[4] a52 = [5,6,7,8];
1062 
1063 void test52()
1064 {
1065   int x=3;
1066   assert(a52[x]==8);
1067 }
1068 
1069 /***************************************************/
1070 
1071 void test53()
1072 {
1073     size_t func2(immutable(void)[] t)
1074     {
1075         return 0;
1076     }
1077 }
1078 
1079 /***************************************************/
1080 
1081 void foo54(void delegate(void[]) dg) { }
1082 
1083 void test54()
1084 {
1085     void func(void[] t) pure { }
1086     foo54(&func);
1087 
1088 //    void func2(const(void)[] t) { }
1089 //    foo54(&func2);
1090 }
1091 
1092 /***************************************************/
1093 
1094 class Foo55
1095 {
1096     synchronized void noop1() { }
1097     void noop2() shared { }
1098 }
1099 
1100 void test55()
1101 {
1102     auto foo = new shared(Foo55);
1103     foo.noop1();
1104     foo.noop2();
1105 }
1106 
1107 /***************************************************/
1108 
1109 enum float one56 = 1 * 1;
1110 template X56(float E) { int X56 = 2; }
1111 alias X56!(one56 * one56) Y56;
1112 
1113 void test56()
1114 {
1115     assert(Y56 == 2);
1116 }
1117 
1118 /***************************************************/
1119 
1120 void test57()
1121 {
1122     alias shared(int) T;
1123     assert (is(T == shared));
1124 }
1125 
1126 /***************************************************/
1127 
1128 struct A58
1129 {
1130   int a,b;
1131 }
1132 
1133 void test58()
1134 {
1135   A58[2] rg=[{1,2},{5,6}];
1136   assert(rg[0].a == 1);
1137   assert(rg[0].b == 2);
1138   assert(rg[1].a == 5);
1139   assert(rg[1].b == 6);
1140 }
1141 
1142 /***************************************************/
1143 
1144 class A59 {
1145     const foo(int i)  { return i; }
1146 }
1147 
1148 /***************************************************/
1149 
1150 void test60()
1151 {
1152     enum real ONE = 1.0;
1153     real x;
1154     for (x=0.0; x<10.0; x+=ONE)
1155         printf("%Lg\n", x);
1156     printf("%Lg\n", x);
1157     assert(x == 10);
1158 }
1159 
1160 /***************************************************/
1161 
1162 pure immutable(T)[] fooPT(T)(immutable(T)[] x, immutable(T)[] y){
1163 
1164   immutable(T)[] fooState;
1165 
1166   immutable(T)[] bar(immutable(T)[] x){
1167     fooState = "hello ";
1168     return x ~ y;
1169   }
1170 
1171   return fooState ~ bar(x);
1172 
1173 }
1174 
1175 
1176 void test61()
1177 {
1178     auto s = fooPT("p", "c");
1179     printf("%.*s\n", cast(int)s.length, s.ptr);
1180 }
1181 
1182 /***************************************************/
1183 
1184 void test9577()
1185 {
1186     static int function(int)[] foo = [x => x];
1187     foo[0](0);
1188 }
1189 
1190 /***************************************************/
1191 
1192 int[3] foo62(int[3] a)
1193 {
1194     a[1]++;
1195     return a;
1196 }
1197 
1198 void test62()
1199 {
1200     int[3] b;
1201     b[0] = 1;
1202     b[1] = 2;
1203     b[2] = 3;
1204     auto c = foo62(b);
1205     assert(b[0] == 1);
1206     assert(b[1] == 2);
1207     assert(b[2] == 3);
1208 
1209     assert(c[0] == 1);
1210     assert(c[1] == 3);
1211     assert(c[2] == 3);
1212 }
1213 
1214 /***************************************************/
1215 
1216 void test3927()
1217 {
1218     int[] array;
1219     assert(array.length++ == 0);
1220     assert(array.length == 1);
1221     assert(array.length-- == 1);
1222     assert(array.length == 0);
1223 }
1224 
1225 /***************************************************/
1226 
1227 void test63()
1228 {
1229     int[3] b;
1230     b[0] = 1;
1231     b[1] = 2;
1232     b[2] = 3;
1233     auto c = b;
1234     b[1]++;
1235     assert(b[0] == 1);
1236     assert(b[1] == 3);
1237     assert(b[2] == 3);
1238 
1239     assert(c[0] == 1);
1240     assert(c[1] == 2);
1241     assert(c[2] == 3);
1242 }
1243 
1244 /***************************************************/
1245 
1246 void test64()
1247 {
1248     int[3] b;
1249     b[0] = 1;
1250     b[1] = 2;
1251     b[2] = 3;
1252     int[3] c;
1253     c = b;
1254     b[1]++;
1255     assert(b[0] == 1);
1256     assert(b[1] == 3);
1257     assert(b[2] == 3);
1258 
1259     assert(c[0] == 1);
1260     assert(c[1] == 2);
1261     assert(c[2] == 3);
1262 }
1263 
1264 /***************************************************/
1265 
1266 int[2] foo65(int[2] a)
1267 {
1268     a[1]++;
1269     return a;
1270 }
1271 
1272 void test65()
1273 {
1274     int[2] b;
1275     b[0] = 1;
1276     b[1] = 2;
1277     int[2] c = foo65(b);
1278     assert(b[0] == 1);
1279     assert(b[1] == 2);
1280 
1281     assert(c[0] == 1);
1282     assert(c[1] == 3);
1283 }
1284 
1285 /***************************************************/
1286 
1287 int[1] foo66(int[1] a)
1288 {
1289     a[0]++;
1290     return a;
1291 }
1292 
1293 void test66()
1294 {
1295     int[1] b;
1296     b[0] = 1;
1297     int[1] c = foo66(b);
1298     assert(b[0] == 1);
1299     assert(c[0] == 2);
1300 }
1301 
1302 /***************************************************/
1303 
1304 int[2] foo67(out int[2] a)
1305 {
1306     a[0] = 5;
1307     a[1] = 6;
1308     return a;
1309 }
1310 
1311 void test67()
1312 {
1313     int[2] b;
1314     b[0] = 1;
1315     b[1] = 2;
1316     int[2] c = foo67(b);
1317     assert(b[0] == 5);
1318     assert(b[1] == 6);
1319 
1320     assert(c[0] == 5);
1321     assert(c[1] == 6);
1322 }
1323 
1324 /***************************************************/
1325 
1326 void test68()
1327 {
1328     digestToString(cast(ubyte[16])"\xc3\xfc\xd3\xd7\x61\x92\xe4\x00\x7d\xfb\x49\x6c\xca\x67\xe1\x3b");
1329 }
1330 
1331 void digestToString(const ubyte[16] digest)
1332 {
1333     assert(digest[0] == 0xc3);
1334     assert(digest[15] == 0x3b);
1335 }
1336 
1337 /***************************************************/
1338 
1339 void test69()
1340 {
1341     digestToString69(cast(ubyte[16])"\xc3\xfc\xd3\xd7\x61\x92\xe4\x00\x7d\xfb\x49\x6c\xca\x67\xe1\x3b");
1342 }
1343 
1344 void digestToString69(ref const ubyte[16] digest)
1345 {
1346     assert(digest[0] == 0xc3);
1347     assert(digest[15] == 0x3b);
1348 }
1349 
1350 /***************************************************/
1351 
1352 void test70()
1353 {
1354     digestToString70("1234567890123456");
1355 }
1356 
1357 void digestToString70(ref const char[16] digest)
1358 {
1359     assert(digest[0] == '1');
1360     assert(digest[15] == '6');
1361 }
1362 
1363 /***************************************************/
1364 
1365 void foo71(out shared int o) {}
1366 
1367 /***************************************************/
1368 
1369 struct foo72
1370 {
1371   int bar() shared { return 1; }
1372 }
1373 
1374 void test72()
1375 {
1376   shared foo72 f;
1377   auto x = f.bar;
1378 }
1379 
1380 /***************************************************/
1381 
1382 class Foo73
1383 {
1384   static if (is(typeof(this) T : shared T))
1385     static assert(0);
1386   static if (is(typeof(this) U == shared U))
1387     static assert(0);
1388   static if (is(typeof(this) U == const U))
1389     static assert(0);
1390   static if (is(typeof(this) U == immutable U))
1391     static assert(0);
1392   static if (is(typeof(this) U == const shared U))
1393     static assert(0);
1394 
1395   static assert(!is(int == const));
1396   static assert(!is(int == immutable));
1397   static assert(!is(int == shared));
1398 
1399   static assert(is(int == int));
1400   static assert(is(const(int) == const));
1401   static assert(is(immutable(int) == immutable));
1402   static assert(is(shared(int) == shared));
1403   static assert(is(const(shared(int)) == shared));
1404   static assert(is(const(shared(int)) == const));
1405 
1406   static assert(!is(const(shared(int)) == immutable));
1407   static assert(!is(const(int) == immutable));
1408   static assert(!is(const(int) == shared));
1409   static assert(!is(shared(int) == const));
1410   static assert(!is(shared(int) == immutable));
1411   static assert(!is(immutable(int) == const));
1412   static assert(!is(immutable(int) == shared));
1413 }
1414 
1415 template Bar(T : T)
1416 {
1417     alias T Bar;
1418 }
1419 
1420 template Barc(T : const(T))
1421 {
1422     alias T Barc;
1423 }
1424 
1425 template Bari(T : immutable(T))
1426 {
1427     alias T Bari;
1428 }
1429 
1430 template Bars(T : shared(T))
1431 {
1432     alias T Bars;
1433 }
1434 
1435 template Barsc(T : shared(const(T)))
1436 {
1437     alias T Barsc;
1438 }
1439 
1440 
1441 void test73()
1442 {
1443     auto f = new Foo73;
1444 
1445     alias int T;
1446 
1447     // 5*5 == 25 combinations, plus 2 for swapping const and shared
1448 
1449     static assert(is(Bar!(T) == T));
1450     static assert(is(Bar!(const(T)) == const(T)));
1451     static assert(is(Bar!(immutable(T)) == immutable(T)));
1452     static assert(is(Bar!(shared(T)) == shared(T)));
1453     static assert(is(Bar!(shared(const(T))) == shared(const(T))));
1454 
1455     static assert(is(Barc!(const(T)) == T));
1456     static assert(is(Bari!(immutable(T)) == T));
1457     static assert(is(Bars!(shared(T)) == T));
1458     static assert(is(Barsc!(shared(const(T))) == T));
1459 
1460     static assert(is(Barc!(T) == T));
1461     static assert(is(Barc!(immutable(T)) == T));
1462     static assert(is(Barc!(const(shared(T))) == shared(T)));
1463     static assert(is(Barsc!(immutable(T)) == T));
1464 
1465     static assert(is(Bars!(const(shared(T))) == const(T)));
1466     static assert(is(Barsc!(shared(T)) == T));
1467 
1468     Bars!(shared(const(T))) b;
1469     pragma(msg, typeof(b));
1470 
1471     static assert(is(Bars!(shared(const(T))) == const(T)));
1472     static assert(is(Barc!(shared(const(T))) == shared(T)));
1473 
1474     static assert(!is(Bari!(T)));
1475     static assert(!is(Bari!(const(T))));
1476     static assert(!is(Bari!(shared(T))));
1477     static assert(!is(Bari!(const(shared(T)))));
1478 
1479     static assert(is(Barc!(shared(T))));
1480 
1481     static assert(!is(Bars!(T)));
1482     static assert(!is(Bars!(const(T))));
1483     static assert(!is(Bars!(immutable(T))));
1484     static assert(!is(Barsc!(T)));
1485     static assert(!is(Barsc!(const(T))));
1486 }
1487 
1488 /***************************************************/
1489 
1490 pure nothrow {
1491   alias void function(int) A74;
1492 }
1493 
1494 alias void function(int) pure nothrow B74;
1495 alias pure nothrow void function(int) C74;
1496 
1497 void test74()
1498 {
1499     A74 a = null;
1500     B74 b = null;
1501     C74 c = null;
1502     a = b;
1503     a = c;
1504 }
1505 
1506 /***************************************************/
1507 
1508 void test9212()
1509 {
1510     int[int] aa;
1511     foreach (const key, const val; aa) {}
1512     foreach (size_t key, size_t val; aa) {}
1513 }
1514 
1515 /***************************************************/
1516 
1517 class A75
1518 {
1519     pure static void raise(string s)
1520     {
1521         throw new Exception(s);
1522     }
1523 }
1524 
1525 void test75()
1526 {   int x = 0;
1527     try
1528     {
1529         A75.raise("a");
1530     } catch (Exception e)
1531     {
1532         x = 1;
1533     }
1534     assert(x == 1);
1535 }
1536 
1537 /***************************************************/
1538 
1539 void test76()
1540 {
1541     int x, y;
1542     bool which;
1543     (which ? x : y) += 5;
1544     assert(y == 5);
1545 }
1546 
1547 /***************************************************/
1548 
1549 void test77()
1550 {
1551     auto a = ["hello", "world"];
1552     pragma(msg, typeof(a));
1553     auto b = a;
1554     assert(a is b);
1555     assert(a == b);
1556     b = a.dup;
1557     assert(a == b);
1558     assert(a !is b);
1559 }
1560 
1561 /***************************************************/
1562 
1563 void test78()
1564 {
1565     auto array = [0, 2, 4, 6, 8, 10];
1566     array = array[0 .. $ - 2];         // Right-shrink by two elements
1567     assert(array == [0, 2, 4, 6]);
1568     array = array[1 .. $];             // Left-shrink by one element
1569     assert(array == [2, 4, 6]);
1570     array = array[1 .. $ - 1];         // Shrink from both sides
1571     assert(array == [4]);
1572 }
1573 
1574 /***************************************************/
1575 
1576 void test79()
1577 {
1578     auto a = [87, 40, 10];
1579     a ~= 42;
1580     assert(a == [87, 40, 10, 42]);
1581     a ~= [5, 17];
1582     assert(a == [87, 40, 10, 42, 5, 17]);
1583 }
1584 
1585 /***************************************************/
1586 
1587 void test6317()
1588 {
1589     int b = 12345;
1590     struct nested { int a; int fun() { return b; } }
1591     static assert(!__traits(compiles, { nested x = { 3, null }; }));
1592     nested g = { 7 };
1593     auto h = nested(7);
1594     assert(g.fun() == 12345);
1595     assert(h.fun() == 12345);
1596 }
1597 
1598 /***************************************************/
1599 
1600 void test80()
1601 {
1602     auto array = new int[10];
1603     array.length += 1000;
1604     assert(array.length == 1010);
1605     array.length /= 10;
1606     assert(array.length == 101);
1607     array.length -= 1;
1608     assert(array.length == 100);
1609     array.length |= 1;
1610     assert(array.length == 101);
1611     array.length ^= 3;
1612     assert(array.length == 102);
1613     array.length &= 2;
1614     assert(array.length == 2);
1615     array.length *= 2;
1616     assert(array.length == 4);
1617     array.length <<= 1;
1618     assert(array.length == 8);
1619     array.length >>= 1;
1620     assert(array.length == 4);
1621     array.length >>>= 1;
1622     assert(array.length == 2);
1623     array.length %= 2;
1624     assert(array.length == 0);
1625 
1626     int[]* foo()
1627     {
1628         static int x;
1629         x++;
1630         assert(x == 1);
1631         auto p = &array;
1632         return p;
1633     }
1634 
1635     (*foo()).length += 2;
1636     assert(array.length == 2);
1637 }
1638 
1639 /***************************************************/
1640 
1641 void test81()
1642 {
1643     int[3] a = [1, 2, 3];
1644     int[3] b = a;
1645     a[1] = 42;
1646     assert(b[1] == 2); // b is an independent copy of a
1647     int[3] fun(int[3] x, int[3] y) {
1648        // x and y are copies of the arguments
1649        x[0] = y[0] = 100;
1650        return x;
1651     }
1652     auto c = fun(a, b);         // c has type int[3]
1653     assert(c == [100, 42, 3]);
1654     assert(b == [1, 2, 3]);     // b is unaffected by fun
1655 }
1656 
1657 /***************************************************/
1658 
1659 void test82()
1660 {
1661     auto a1 = [ "Jane":10.0, "Jack":20, "Bob":15 ];
1662     auto a2 = a1;                    // a1 and a2 refer to the same data
1663     a1["Bob"] = 100;                 // Changing a1
1664     assert(a2["Bob"] == 100);        //is same as changing a2
1665     a2["Sam"] = 3.5;                 //and vice
1666     assert(a2["Sam"] == 3.5);        //    versa
1667 }
1668 
1669 /***************************************************/
1670 
1671 void test7942()
1672 {
1673     string a = "a";
1674     wstring b = "b";
1675     dstring c = "c";
1676 
1677     a ~= "a"c;
1678     static assert(!is(typeof(a ~= "b"w)));
1679     static assert(!is(typeof(a ~= "c"d)));
1680     static assert(!is(typeof(b ~= "a"c)));
1681     b ~= "b"w;
1682     static assert(!is(typeof(b ~= "c"d)));
1683     static assert(!is(typeof(c ~= "a"c)));
1684     static assert(!is(typeof(c ~= "b"w)));
1685     c ~= "c"d;
1686 
1687     assert(a == "aa");
1688     assert(b == "bb");
1689     assert(c == "cc");
1690 }
1691 
1692 /***************************************************/
1693 
1694 void bump(ref int x) { ++x; }
1695 
1696 void test83()
1697 {
1698    int x = 1;
1699    bump(x);
1700    assert(x == 2);
1701 }
1702 
1703 /***************************************************/
1704 
1705 interface Test4174
1706 {
1707     void func(T)() {}
1708 }
1709 
1710 /***************************************************/
1711 
1712 auto foo84 = [1, 2.4];
1713 
1714 void test84()
1715 {
1716     pragma(msg, typeof([1, 2.4]));
1717     static assert(is(typeof([1, 2.4]) == double[]));
1718 
1719     pragma(msg, typeof(foo84));
1720     static assert(is(typeof(foo84) == double[]));
1721 }
1722 
1723 /***************************************************/
1724 
1725 void test85()
1726 {
1727     dstring c = "V\u00E4rld";
1728     c = c ~ '!';
1729     assert(c == "V\u00E4rld!");
1730     c = '@' ~ c;
1731     assert(c == "@V\u00E4rld!");
1732 
1733     wstring w = "V\u00E4rld";
1734     w = w ~ '!';
1735     assert(w == "V\u00E4rld!");
1736     w = '@' ~ w;
1737     assert(w == "@V\u00E4rld!");
1738 
1739     string s = "V\u00E4rld";
1740     s = s ~ '!';
1741     assert(s == "V\u00E4rld!");
1742     s = '@' ~ s;
1743     assert(s == "@V\u00E4rld!");
1744 }
1745 
1746 /***************************************************/
1747 
1748 void test86()
1749 {
1750     int[][] a = [ [1], [2,3], [4] ];
1751     int[][] w = [ [1, 2], [3], [4, 5], [] ];
1752     int[][] x = [ [], [1, 2], [3], [4, 5], [] ];
1753 }
1754 
1755 /***************************************************/
1756 
1757 // https://issues.dlang.org/show_bug.cgi?id=3379
1758 
1759 T1[] find(T1, T2)(T1[] longer, T2[] shorter)
1760    if (is(typeof(longer[0 .. 1] == shorter) : bool))
1761 {
1762    while (longer.length >= shorter.length) {
1763       if (longer[0 .. shorter.length] == shorter) break;
1764       longer = longer[1 .. $];
1765    }
1766    return longer;
1767 }
1768 
1769 auto max(T...)(T a)
1770       if (T.length == 2
1771          && is(typeof(a[1] > a[0] ? a[1] : a[0]))
1772        || T.length > 2
1773          && is(typeof(max(max(a[0], a[1]), a[2 .. $])))) {
1774    static if (T.length == 2) {
1775       return a[1] > a[0] ? a[1] : a[0];
1776    } else {
1777       return max(max(a[0], a[1]), a[2 .. $]);
1778    }
1779 }
1780 
1781 // Cases which would ICE or segfault
1782 struct Bulldog(T){
1783     static void cat(Frog)(Frog f) if (true)
1784     {    }
1785 }
1786 
1787 void mouse(){
1788     Bulldog!(int).cat(0);
1789 }
1790 
1791 void test87()
1792 {
1793     double[] d1 = [ 6.0, 1.5, 2.4, 3 ];
1794     double[] d2 = [ 1.5, 2.4 ];
1795     assert(find(d1, d2) == d1[1 .. $]);
1796     assert(find(d1, d2) == d1[1 .. $]); // Check for memory corruption
1797     assert(max(4, 5) == 5);
1798     assert(max(3, 4, 5) == 5);
1799 }
1800 
1801 /***************************************************/
1802 
1803 template test4284(alias v) { enum test4284 = v.length == 0; }
1804 static assert(test4284!(cast(string)null));
1805 static assert(test4284!(cast(string[])null));
1806 
1807 /***************************************************/
1808 
1809 struct S88
1810 {
1811     void opDispatch(string s, T)(T i)
1812     {
1813         printf("S.opDispatch('%.*s', %d)\n", cast(int)s.length, s.ptr, i);
1814     }
1815 }
1816 
1817 class C88
1818 {
1819     void opDispatch(string s)(int i)
1820     {
1821         printf("C.opDispatch('%.*s', %d)\n", cast(int)s.length, s.ptr, i);
1822     }
1823 }
1824 
1825 struct D88
1826 {
1827     template opDispatch(string s)
1828     {
1829         enum int opDispatch = 8;
1830     }
1831 }
1832 
1833 void test88()
1834 {
1835     S88 s;
1836     s.opDispatch!("hello")(7);
1837     s.foo(7);
1838 
1839     auto c = new C88();
1840     c.foo(8);
1841 
1842     D88 d;
1843     printf("d.foo = %d\n", d.foo);
1844     assert(d.foo == 8);
1845 }
1846 
1847 /***************************************************/
1848 
1849 void test89() {
1850     static struct X {
1851         int x;
1852         int bar() { return x; }
1853     }
1854     X s;
1855     printf("%zd\n", s.sizeof);
1856     assert(s.sizeof == 4);
1857 }
1858 
1859 /***************************************************/
1860 
1861 struct S90
1862 {
1863     void opDispatch( string name, T... )( T values )
1864     {
1865         assert(values[0] == 3.14);
1866     }
1867 }
1868 
1869 void test90( )
1870 {   S90 s;
1871     s.opDispatch!("foo")( 3.14 );
1872     s.foo( 3.14 );
1873 }
1874 
1875 /***************************************************/
1876 
1877 struct A7439(int r, int c)
1878 {
1879     alias r R;
1880     alias c C;
1881     alias float[R * C] Data;
1882     Data _data;
1883     alias _data this;
1884 
1885     this(Data ar){ _data = ar; }
1886 
1887     pure ref float opIndex(size_t rr, size_t cc){ return _data[cc + rr * C]; }
1888 }
1889 
1890 void test7439()
1891 {
1892     A7439!(2, 2) a = A7439!(2, 2)([8, 3, 2, 9]);
1893     a[0,0] -= a[0,0] * 2.0;
1894 }
1895 
1896 /***************************************************/
1897 
1898 void foo91(uint line = __LINE__) { printf("%d\n", line); }
1899 
1900 void test91()
1901 {
1902     foo91();
1903     printf("%d\n", __LINE__);
1904 }
1905 
1906 /***************************************************/
1907 
1908 bool fun13468(Object e, typeof(null) needle)
1909 {
1910     return (e == needle);
1911 }
1912 
1913 void test13468()
1914 {
1915     assert(fun13468(null, null));
1916 }
1917 
1918 /***************************************************/
1919 
1920 auto ref foo92(ref int x) { return x; }
1921 int bar92(ref int x) { return x; }
1922 
1923 void test92()
1924 {
1925     int x = 3;
1926     int i = bar92(foo92(x));
1927     assert(i == 3);
1928 }
1929 
1930 /***************************************************/
1931 
1932 struct Foo93
1933 {
1934     public int foo() const
1935     {
1936         return 2;
1937     }
1938 }
1939 
1940 void test93()
1941 {
1942     const Foo93 bar = Foo93();
1943     enum bla = bar.foo();
1944     assert(bla == 2);
1945 }
1946 
1947 /***************************************************/
1948 
1949 
1950 extern(C++) class C1687
1951 {
1952     void func() {}
1953 }
1954 
1955 void test1687()
1956 {
1957     auto c = new C1687();
1958     assert(c.__vptr[0] == (&c.func).funcptr);
1959 }
1960 
1961 /***************************************************/
1962 
1963 struct Foo94
1964 {
1965     int x, y;
1966     real z;
1967 }
1968 
1969 pure nothrow Foo94 makeFoo(const int x, const int y)
1970 {
1971     return Foo94(x, y, 3.0);
1972 }
1973 
1974 void test94()
1975 {
1976     auto f = makeFoo(1, 2);
1977     assert(f.x==1);
1978     assert(f.y==2);
1979     assert(f.z==3);
1980 }
1981 
1982 /***************************************************/
1983 
1984 struct T95
1985 {
1986     @disable this(this)
1987     {
1988     }
1989 }
1990 
1991 struct S95
1992 {
1993     T95 t;
1994 }
1995 
1996 @disable void foo95() { }
1997 
1998 struct T95A
1999 {
2000     @disable this(this);
2001 }
2002 
2003 struct S95A
2004 {
2005     T95A t;
2006 }
2007 
2008 @disable void foo95A() { }
2009 
2010 void test95()
2011 {
2012     S95 s;
2013     S95 t;
2014     static assert(!__traits(compiles, t = s));
2015     static assert(!__traits(compiles, foo95()));
2016 
2017     S95A u;
2018     S95A v;
2019     static assert(!__traits(compiles, v = u));
2020     static assert(!__traits(compiles, foo95A()));
2021 }
2022 
2023 /***************************************************/
2024 
2025 struct S96(alias init)
2026 {
2027     int[] content = init;
2028 }
2029 
2030 void test96()
2031 {
2032     S96!([12, 3]) s1;
2033     S96!([1, 23]) s2;
2034     //writeln(s1.content);
2035     //writeln(s2.content);
2036     assert(!is(typeof(s1) == typeof(s2)));
2037 }
2038 
2039 /***************************************************/
2040 
2041 struct A97
2042 {
2043     const bool opEquals(ref const A97) { return true; }
2044     ref A97 opUnary(string op)() if (op == "++")
2045     {
2046         return this;
2047     }
2048 }
2049 
2050 void test97()
2051 {
2052     A97 a, b;
2053     foreach (e; a .. b) {
2054     }
2055 }
2056 
2057 /***************************************************/
2058 
2059 void test98()
2060 {
2061     auto a = new int[2];
2062     // the name "length" should not pop up in an index expression
2063     static assert(!is(typeof(a[length - 1])));
2064 }
2065 
2066 /***************************************************/
2067 
2068 string s99;
2069 
2070 void bar99(string i)
2071 {
2072 }
2073 
2074 void function(string) foo99(string i)
2075 {
2076     return &bar99;
2077 }
2078 
2079 void test99()
2080 {
2081     foo99 (s99 ~= "a") (s99 ~= "b");
2082     assert(s99 == "ab");
2083 }
2084 
2085 /***************************************************/
2086 // https://issues.dlang.org/show_bug.cgi?id=5081
2087 
2088 void test5081()
2089 {
2090     static pure immutable(int[]) x1()
2091     {
2092         int[] a = new int[](10);
2093         return a;
2094     }
2095     static pure immutable(int[]) x2(int len)
2096     {
2097         int[] a = new int[](len);
2098         return a;
2099     }
2100     static pure immutable(int[]) x3(immutable(int[]) org)
2101     {
2102         int[] a = new int[](org.length);
2103         return a;
2104     }
2105 
2106     immutable a1 = x1();
2107     immutable a2 = x2(10);
2108     immutable a3 = x3([1,2]);
2109 
2110     static pure int[] y1()
2111     {
2112         return new int[](10);
2113     }
2114 
2115     immutable b1 = y1();
2116 }
2117 
2118 /***************************************************/
2119 
2120 void test100()
2121 {
2122    string s;
2123 
2124    /* Testing order of evaluation */
2125    void delegate(string, string) fun(string) {
2126       s ~= "b";
2127       return delegate void(string x, string y) { s ~= "e"; };
2128    }
2129    fun(s ~= "a")(s ~= "c", s ~= "d");
2130    assert(s == "abcde", s);
2131 }
2132 
2133 /***************************************************/
2134 
2135 void test101()
2136 {
2137    int[] d1 = [ 6, 1, 2 ];
2138    byte[] d2 = [ 6, 1, 2 ];
2139    assert(d1 == d2);
2140    d2 ~= [ 6, 1, 2 ];
2141    assert(d1 != d2);
2142 }
2143 
2144 /***************************************************/
2145 
2146 
2147 void test5403()
2148 {
2149     struct S
2150     {
2151         static int front;
2152         enum back = "yes!";
2153         bool empty;
2154         void popAny() { empty = true; }
2155         alias popAny popFront;
2156         alias popAny popBack;
2157     }
2158     S.front = 7;
2159     foreach(int i; S()) assert(i == 7);
2160     S.front = 2;
2161     foreach(i; S()) assert(i == 2);
2162     foreach_reverse(i; S()) assert(i == "yes!");
2163 }
2164 
2165 /***************************************************/
2166 
2167 static assert([1,2,3] == [1.0,2,3]);
2168 
2169 /***************************************************/
2170 
2171 int transmogrify(uint) { return 1; }
2172 int transmogrify(long) { return 2; }
2173 
2174 void test103()
2175 {
2176     assert(transmogrify(42) == 1);
2177 }
2178 
2179 /***************************************************/
2180 
2181 int foo104(int x)
2182 {
2183     int* p = &(x += 1);
2184     return *p;
2185 }
2186 
2187 int bar104(int *x)
2188 {
2189     int* p = &(*x += 1);
2190     return *p;
2191 }
2192 
2193 void test104()
2194 {
2195     auto i = foo104(1);
2196     assert(i == 2);
2197     i = bar104(&i);
2198     assert(i == 3);
2199 }
2200 
2201 /***************************************************/
2202 
2203 ref int bump105(return ref int x) { return ++x; }
2204 
2205 void test105()
2206 {
2207    int x = 1;
2208    bump105(bump105(x)); // two increments
2209    assert(x == 3);
2210 }
2211 
2212 /***************************************************/
2213 
2214 pure int genFactorials(int n) {
2215     static pure int factorial(int n) {
2216       if (n==2) return 1;
2217       return factorial(2);
2218     }
2219     return factorial(n);
2220 }
2221 
2222 /***************************************************/
2223 
2224 void test107()
2225 {
2226     int[6] a;
2227     //writeln(a);
2228     //writeln(a.init);
2229     assert(a.init == [0,0,0,0,0,0]);
2230 }
2231 
2232 /***************************************************/
2233 
2234 class A109 {}
2235 
2236 void test109()
2237 {
2238     immutable(A109) b;
2239     A109 c;
2240     auto z = true ? b : c;
2241     //writeln(typeof(z).stringof);
2242     static assert(is(typeof(z) == const(A109)));
2243 }
2244 
2245 /***************************************************/
2246 
2247 template Boo(T) {}
2248 struct Foo110(T, alias V = Boo!T)
2249 {
2250     pragma(msg, V.stringof);
2251     static const s = V.stringof;
2252 }
2253 alias Foo110!double B110;
2254 alias Foo110!int A110;
2255 
2256 static assert(B110.s == "Boo!double");
2257 static assert(A110.s == "Boo!int");
2258 
2259 /***************************************************/
2260 
2261 int test11247()
2262 {
2263     static assert(is(byte[typeof(int.init).sizeof] == byte[4]));
2264     static assert(is(byte[typeof(return).sizeof] == byte[4]));
2265     return 0;
2266 }
2267 
2268 /***************************************************/
2269 
2270 // https://issues.dlang.org/show_bug.cgi?id=3716
2271 void test111()
2272 {
2273     auto k1 = true ? [1,2] : []; // OK
2274     auto k2 = true ? [[1,2]] : [[]];
2275     auto k3 = true ? [] : [[1,2]];
2276     auto k4 = true ? [[[]]] : [[[1,2]]];
2277     auto k5 = true ? [[[1,2]]] : [[[]]];
2278     auto k6 = true ? [] : [[[]]];
2279     static assert(!is(typeof(true ? [[[]]] : [[1,2]]))); // Must fail
2280 }
2281 
2282 /***************************************************/
2283 // https://issues.dlang.org/show_bug.cgi?id=658
2284 
2285 void test658()
2286 {
2287     struct S { int i; }
2288     class C { int i; }
2289 
2290     S s;
2291     S* sp = &s;
2292     with (sp) i = 42;
2293     assert(s.i == 42);
2294     with (&s) i = 43;
2295     assert(s.i == 43);
2296 
2297     C c = new C;
2298     C* cp = &c;
2299     with (cp) i = 42;
2300     assert(c.i == 42);
2301     with (&c) i = 43;
2302     assert(c.i == 43);
2303 }
2304 
2305 /***************************************************/
2306 
2307 void test3069()
2308 {
2309     ubyte id = 0;
2310     void[] v = [id] ~ [id];
2311 }
2312 
2313 /***************************************************/
2314 // https://issues.dlang.org/show_bug.cgi?id=4303
2315 
2316 template foo112() if (__traits(compiles,undefined))
2317 {
2318     enum foo112 = false;
2319 }
2320 
2321 template foo112() if (true)
2322 {
2323     enum foo112 = true;
2324 }
2325 
2326 pragma(msg,__traits(compiles,foo112!()));
2327 static assert(__traits(compiles,foo112!()));
2328 
2329 const bool bar112 = foo112!();
2330 
2331 
2332 /***************************************************/
2333 
2334 struct File113
2335 {
2336     this(int name) { }
2337 
2338     ~this() { }
2339 
2340     void opAssign(File113 rhs) { }
2341 
2342     struct ByLine
2343     {
2344         File113 file;
2345 
2346         this(int) { }
2347 
2348     }
2349 
2350     ByLine byLine()
2351     {
2352         return ByLine(1);
2353     }
2354 }
2355 
2356 auto filter113(File113.ByLine rs)
2357 {
2358     struct Filter
2359     {
2360         this(File113.ByLine r) { }
2361     }
2362 
2363     return Filter(rs);
2364 }
2365 
2366 void test113()
2367 {
2368     auto f = File113(1);
2369     auto rx = f.byLine();
2370     auto file = filter113(rx);
2371 }
2372 
2373 /***************************************************/
2374 
2375 template foo114(fun...)
2376 {
2377     auto foo114(int[] args)
2378     {
2379         return 1;
2380     }
2381 }
2382 
2383 pragma(msg, typeof(foo114!"a + b"([1,2,3])));
2384 
2385 /***************************************************/
2386 // https://issues.dlang.org/show_bug.cgi?id=3935
2387 
2388 struct Foo115 {
2389     void opBinary(string op)(Foo other) {
2390         pragma(msg, "op: " ~ op);
2391         assert(0);
2392     }
2393 }
2394 
2395 void test115()
2396 {
2397     Foo115 f;
2398     f = f;
2399 }
2400 
2401 /***************************************************/
2402 // https://issues.dlang.org/show_bug.cgi?id=2477
2403 
2404 void foo116(T,)(T t) { T x; }
2405 
2406 void test116()
2407 {
2408     int[] data = [1,2,3,];  // OK
2409 
2410     data = [ 1,2,3, ];  // fails
2411     auto i = data[1,];
2412     foo116!(int)(3);
2413     foo116!(int,)(3);
2414     foo116!(int,)(3,);
2415 }
2416 
2417 /***************************************************/
2418 
2419 void test1891()
2420 {
2421     struct C {
2422         char[8] x = "helloabc";
2423     }
2424 
2425     int main()
2426     {
2427         C* a = new C;
2428         C*[] b;
2429         b ~= new C;
2430 
2431         auto g = a ~ b;
2432         assert(g[0] && g[1] && g[0].x == g[1].x);
2433 
2434         return 0;
2435     }
2436 }
2437 
2438 /***************************************************/
2439 // https://issues.dlang.org/show_bug.cgi?id=4291
2440 
2441 void test117() pure
2442 {
2443     mixin declareVariable;
2444     var = 42;
2445     mixin declareFunction;
2446     readVar();
2447 }
2448 template declareVariable() { int var; }
2449 template declareFunction()
2450 {
2451     int readVar() { return var; }
2452 }
2453 
2454 /***************************************************/
2455 // https://issues.dlang.org/show_bug.cgi?id=4177
2456 
2457 pure real log118(real x) {
2458     if (__ctfe)
2459         return 0.0;
2460     else
2461         return 1.0;
2462 }
2463 
2464 enum x118 = log118(4.0);
2465 
2466 void test118() {}
2467 
2468 /***************************************************/
2469 
2470 void bug4465()
2471 {
2472     const a = 2 ^^ 2;
2473     int b = a;
2474 }
2475 
2476 /***************************************************/
2477 
2478 pure void foo(int *p)
2479 {
2480     *p = 3;
2481 }
2482 
2483 pure void test120()
2484 {
2485     int i;
2486     foo(&i);
2487     assert(i == 3);
2488 }
2489 
2490 /***************************************************/
2491 // https://issues.dlang.org/show_bug.cgi?id=4866
2492 
2493 immutable int[3] statik = [ 1, 2, 3 ];
2494 enum immutable(int)[] dynamic = statik;
2495 
2496 static assert(is(typeof(dynamic) == immutable(int)[]));
2497 static if (! is(typeof(dynamic) == immutable(int)[]))
2498 {
2499     static assert(0);   // (7)
2500 }
2501 pragma(msg, "!! ", typeof(dynamic));
2502 
2503 /***************************************************/
2504 // https://issues.dlang.org/show_bug.cgi?id=2943
2505 
2506 struct Foo2943
2507 {
2508     int a;
2509     int b;
2510     alias b this;
2511 }
2512 
2513 void test122()
2514 {
2515     Foo2943 foo, foo2;
2516     foo.a = 1;
2517     foo.b = 2;
2518     foo2.a = 3;
2519     foo2.b = 4;
2520 
2521     foo2 = foo;
2522     assert(foo2.a == foo.a);
2523 }
2524 
2525 /***************************************************/
2526 // https://issues.dlang.org/show_bug.cgi?id=4641
2527 
2528 struct S123 {
2529     int i;
2530     alias i this;
2531 }
2532 
2533 void test123() {
2534     S123[int] ss;
2535     ss[0] = S123.init; // This line causes Range Violation.
2536 }
2537 
2538 /***************************************************/
2539 // https://issues.dlang.org/show_bug.cgi?id=2451
2540 
2541 struct Foo124 {
2542     int z = 3;
2543     void opAssign(Foo124 x) { z= 2;}
2544 }
2545 
2546 struct Bar124 {
2547     int z = 3;
2548     this(this){ z = 17; }
2549 }
2550 
2551 void test124() {
2552     Foo124[string] stuff;
2553     stuff["foo"] = Foo124.init;
2554     assert(stuff["foo"].z == 3);
2555     stuff["foo"] = Foo124.init;
2556     assert(stuff["foo"].z == 2);
2557 
2558     Bar124[string] stuff2;
2559     Bar124 q;
2560     stuff2["dog"] = q;
2561     assert(stuff2["dog"].z == 17);
2562 }
2563 
2564 /***************************************************/
2565 
2566 void doNothing() {}
2567 
2568 void bug5071(short d, ref short c) {
2569    assert(c==0x76);
2570 
2571     void closure() {
2572         auto c2 = c;
2573         auto d2 = d;
2574         doNothing();
2575     }
2576     auto useless = &closure;
2577 }
2578 
2579 void test125()
2580 {
2581    short c = 0x76;
2582    bug5071(7, c);
2583 }
2584 
2585 /***************************************************/
2586 
2587 struct Foo126
2588 {
2589    static Foo126 opCall(in Foo126 _f) pure
2590    {
2591        return _f;
2592    }
2593 }
2594 
2595 /***************************************************/
2596 
2597 void test796()
2598 {
2599     struct S { invariant() { throw new Exception(""); } }
2600     S* s;
2601     try {
2602         assert(s);
2603     } catch (Error) {
2604     }
2605 }
2606 
2607 /***************************************************/
2608 
2609 void test7077()
2610 {
2611     if(0) mixin("auto x = 2;");
2612     auto x = 1;
2613 }
2614 
2615 /***************************************************/
2616 
2617 struct Tuple127(S...)
2618 {
2619     S expand;
2620     alias expand this;
2621 }
2622 
2623 alias Tuple127!(int, int) Foo127;
2624 
2625 void test127()
2626 {
2627     Foo127[] m_array;
2628     Foo127 f;
2629     m_array ~= f;
2630 }
2631 
2632 /***************************************************/
2633 
2634 struct Bug4434 {}
2635 alias const Bug4434* IceConst4434;
2636 alias shared Bug4434* IceShared4434;
2637 alias shared Bug4434[] IceSharedArray4434;
2638 alias immutable Bug4434* IceImmutable4434;
2639 alias shared const Bug4434* IceSharedConst4434;
2640 
2641 alias int MyInt4434;
2642 alias const MyInt4434[3] IceConstInt4434;
2643 
2644 alias immutable string[] Bug4830;
2645 
2646 /***************************************************/
2647 // https://issues.dlang.org/show_bug.cgi?id=4254
2648 
2649 void bub(const inout int other) {}
2650 
2651 void test128()
2652 {
2653     bub(1);
2654 }
2655 
2656 
2657 /***************************************************/
2658 
2659 pure nothrow @safe auto bug4915a() {  return 0; }
2660 pure nothrow @safe int  bug4915b() { return bug4915a(); }
2661 
2662 void bug4915c()
2663 {
2664     pure nothrow @safe int d() { return 0; }
2665     int e() pure nothrow @safe { return d(); }
2666 }
2667 
2668 /***************************************************/
2669 // https://issues.dlang.org/show_bug.cgi?id=5164
2670 
2671 static if (is(int Q == int, Z...))  { }
2672 
2673 /***************************************************/
2674 // https://issues.dlang.org/show_bug.cgi?id=5195
2675 
2676 alias typeof(foo5195) food5195;
2677 const int * foo5195 = null;
2678 alias typeof(foo5195) good5195;
2679 static assert( is (food5195 == good5195));
2680 
2681 /***************************************************/
2682 
2683 version (Windows)
2684 {
2685 }
2686 else
2687 {
2688 int[0] var5332;
2689 void test5332() { auto x = var5332; }
2690 }
2691 
2692 /***************************************************/
2693 // https://issues.dlang.org/show_bug.cgi?id=5191
2694 
2695 struct Foo129
2696 {
2697     void add(T)(T value) nothrow
2698     {
2699         this.value += value;
2700     }
2701 
2702     this(int value)
2703     {
2704         this.value = value;
2705     }
2706 
2707     int value;
2708 }
2709 
2710 void test129()
2711 {
2712     auto foo = Foo129(5);
2713     assert(foo.value == 5);
2714 
2715     foo.add(2);
2716     printf("%d\n", foo.value);
2717     assert(foo.value == 7);
2718 
2719     foo.add(3);
2720     printf("%d\n", foo.value);
2721     assert(foo.value == 10);
2722 
2723     foo.add(3);
2724     printf("%d\n", foo.value);
2725     assert(foo.value == 13);
2726 
2727     void delegate (int) nothrow dg = &foo.add!(int);
2728     dg(7);
2729     assert(foo.value == 20);
2730 }
2731 
2732 /***************************************************/
2733 // https://issues.dlang.org/show_bug.cgi?id=6169
2734 
2735 auto ctfefunc6169() { return "{}"; }
2736 enum ctfefptr6169 = &ctfefunc6169;
2737 int ctfefunc6169a() { return 1; }
2738 template x6169(string c) { alias int x6169; }
2739 template TT6169(T...) { alias T TT6169; }
2740 @property ctfeprop6169() { return "g"; }
2741 
2742 void test6169() pure @safe
2743 {
2744     enum a = ctfefunc6169();
2745     static b = ctfefunc6169();
2746     x6169!(ctfefunc6169()) tt;
2747     mixin(ctfefunc6169());
2748     static if(ctfefunc6169()) {}
2749     pragma(msg, ctfefunc6169());
2750     enum xx
2751     {
2752         k = 0,
2753         j = ctfefunc6169a()
2754     }
2755     auto g = mixin('"' ~ ctfefunc6169() ~ '"');
2756     //auto h = import("testx.d" ~ false ? ctfefunc() : "");
2757     alias TT6169!(int, int)[ctfefunc6169a()..ctfefunc6169a()] i;
2758     alias TT6169!(int, int)[ctfefunc6169a()] j;
2759     int[ctfefunc6169a()+1] k;
2760     alias int[ctfefunc6169a()] l;
2761     switch(1)
2762     {
2763     //case ctfefunc6169a(): // Can't do this because of case variables
2764     case ctfefunc6169a()+1:
2765         ..
2766     case ctfefunc6169a()+2:
2767     default:
2768         break;
2769     }
2770     static assert(ctfefunc6169a());
2771     void fun(int i : ctfefunc6169a() = ctfefunc6169a(), alias j)() if (ctfefunc6169a()) {}
2772     fun!(ctfefunc6169a(), ctfefunc6169())();
2773     enum z = ctfefptr6169();
2774 
2775     auto p = mixin(ctfeprop6169);
2776 }
2777 
2778 /***************************************************/
2779 // https://issues.dlang.org/show_bug.cgi?id=10506
2780 
2781 void impureFunc10506() {}
2782 string join10506(RoR)(RoR ror)
2783 {
2784     impureFunc10506();
2785     return ror[0] ~ ror[1];
2786 }
2787 
2788 void test10506() pure
2789 {
2790     void foobar() {}
2791 
2792     mixin(["foo", "bar"].join10506()~";");
2793 }
2794 
2795 /***************************************************/
2796 
2797 const shared class C5107
2798 {
2799     int x;
2800 }
2801 
2802 static assert(is(typeof(C5107.x) ==  const)); // okay
2803 static assert(is(typeof(C5107.x) == shared)); // fails!
2804 
2805 /***************************************************/
2806 
2807 immutable struct S3598
2808 {
2809     static void funkcja() { }
2810 }
2811 
2812 /***************************************************/
2813 // https://issues.dlang.org/show_bug.cgi?id=4211
2814 
2815 @safe struct X130
2816 {
2817     void func() {  }
2818 }
2819 
2820 @safe class Y130
2821 {
2822     void func() {  }
2823 }
2824 
2825 @safe void test130()
2826 {
2827     X130 x;
2828     x.func();
2829     auto y = new Y130;
2830     y.func();
2831 }
2832 
2833 /***************************************************/
2834 
2835 template Return(alias fun)
2836 {
2837     static if (is(typeof(fun) R == return)) alias R Return;
2838 }
2839 
2840 interface I4217
2841 {
2842     int  square(int  n);
2843     real square(real n);
2844 }
2845 alias Return!( __traits(getOverloads, I4217, "square")[0] ) R4217;
2846 alias Return!( __traits(getOverloads, I4217, "square")[1] ) S4217;
2847 
2848 static assert(! is(R4217 == S4217));
2849 
2850 /***************************************************/
2851 // https://issues.dlang.org/show_bug.cgi?id=5094
2852 
2853 void test131()
2854 {
2855     S131 s;
2856     int[] conv = s;
2857 }
2858 
2859 struct S131
2860 {
2861     @property int[] get() { return [1,2,3]; }
2862     alias get this;
2863 }
2864 
2865 /***************************************************/
2866 
2867 struct S7545
2868 {
2869     uint id;
2870     alias id this;
2871 }
2872 
2873 void test7545()
2874 {
2875     auto id = 0 ? S7545() : -1;
2876 }
2877 
2878 /***************************************************/
2879 // https://issues.dlang.org/show_bug.cgi?id=5020
2880 
2881 void test132()
2882 {
2883     S132 s;
2884     if (!s) {}
2885 }
2886 
2887 struct S132
2888 {
2889     bool cond;
2890     alias cond this;
2891 }
2892 
2893 /***************************************************/
2894 // https://issues.dlang.org/show_bug.cgi?id=5343
2895 
2896 struct Tuple5343(Specs...)
2897 {
2898     Specs[0] field;
2899 }
2900 
2901 struct S5343(E)
2902 {
2903     immutable E x;
2904 }
2905 enum A5343{a,b,c}
2906 alias Tuple5343!(A5343) TA5343;
2907 alias S5343!(A5343) SA5343;
2908 
2909 /***************************************************/
2910 // https://issues.dlang.org/show_bug.cgi?id=5365
2911 
2912 interface IFactory
2913 {
2914     void foo();
2915 }
2916 
2917 class A133
2918 {
2919     protected static class Factory : IFactory
2920     {
2921         void foo()
2922         {
2923         }
2924     }
2925 
2926     this()
2927     {
2928         _factory = createFactory();
2929     }
2930 
2931     protected IFactory createFactory()
2932     {
2933         return new Factory;
2934     }
2935 
2936     private IFactory _factory;
2937     @property final IFactory factory()
2938     {
2939         return _factory;
2940     }
2941 
2942     alias factory this;
2943 }
2944 
2945 void test133()
2946 {
2947 
2948     IFactory f = new A133;
2949     f.foo(); // segfault
2950 }
2951 
2952 /***************************************************/
2953 // https://issues.dlang.org/show_bug.cgi?id=5365
2954 
2955 class B134
2956 {
2957 }
2958 
2959 class A134
2960 {
2961 
2962     B134 _b;
2963 
2964     this()
2965     {
2966         _b = new B134;
2967     }
2968 
2969     B134 b()
2970     {
2971         return _b;
2972     }
2973 
2974     alias b this;
2975 }
2976 
2977 void test134()
2978 {
2979 
2980     auto a = new A134;
2981     B134 b = a; // b is null
2982     assert(a._b is b); // fails
2983 }
2984 
2985 /***************************************************/
2986 // https://issues.dlang.org/show_bug.cgi?id=5025
2987 
2988 struct S135 {
2989   void delegate() d;
2990 }
2991 
2992 void test135()
2993 {
2994   shared S135[] s;
2995   if (0)
2996     s[0] = S135();
2997 }
2998 
2999 /***************************************************/
3000 // https://issues.dlang.org/show_bug.cgi?id=5545
3001 
3002 bool enforce136(bool value, lazy const(char)[] msg = null) {
3003     if(!value) {
3004         return false;
3005     }
3006 
3007     return value;
3008 }
3009 
3010 struct Perm {
3011     byte[3] perm;
3012     ubyte i;
3013 
3014     this(byte[] input) {
3015         foreach(elem; input) {
3016             enforce136(i < 3);
3017             perm[i++] = elem;
3018             printf("%d\n", i);  // Never gets incremented.  Stays at 0.
3019         }
3020     }
3021 }
3022 
3023 void test136() {
3024     byte[] stuff = [0, 1, 2];
3025     auto perm2 = Perm(stuff);
3026     //writeln(perm2.perm);  // Prints [2, 0, 0]
3027     assert(perm2.perm[] == [0, 1, 2]);
3028 }
3029 
3030 /***************************************************/
3031 // https://issues.dlang.org/show_bug.cgi?id=4097
3032 
3033 void foo4097() { }
3034 alias typeof(&foo4097) T4097;
3035 static assert(is(T4097 X : X*) && is(X == function));
3036 
3037 static assert(!is(X));
3038 
3039 /***************************************************/
3040 // https://issues.dlang.org/show_bug.cgi?id=5798
3041 
3042 void assign9(ref int lhs) pure {
3043     lhs = 9;
3044 }
3045 
3046 void assign8(ref int rhs) pure {
3047     rhs = 8;
3048 }
3049 
3050 int test137(){
3051     int a=1,b=2;
3052     assign8(b),assign9(a);
3053     assert(a == 9);
3054     assert(b == 8);   // <-- fail
3055 
3056     assign9(b),assign8(a);
3057     assert(a == 8);
3058     assert(b == 9);   // <-- fail
3059 
3060     return 0;
3061 }
3062 
3063 /***************************************************/
3064 
3065 // https://issues.dlang.org/show_bug.cgi?id=9366
3066 static assert(!is(typeof((void[]).init ~ cast(void)0)));
3067 static assert(!is(typeof(cast(void)0 ~ (void[]).init)));
3068 
3069 /***************************************************/
3070 
3071 struct Size138
3072 {
3073     union
3074     {
3075         struct
3076         {
3077             int width;
3078             int height;
3079         }
3080 
3081         long size;
3082     }
3083 }
3084 
3085 enum Size138 foo138 = {2 ,5};
3086 
3087 Size138 bar138 = foo138;
3088 
3089 void test138()
3090 {
3091     assert(bar138.width == 2);
3092     assert(bar138.height == 5);
3093 }
3094 
3095 /***************************************************/
3096 
3097 void test3822()
3098 {
3099     import core.stdc.stdlib;
3100     int i = 0;
3101     void* ptr;
3102     while(i++ != 2)
3103     {
3104         auto p = alloca(2);
3105         assert(p != ptr);
3106         ptr = p;
3107     }
3108 }
3109 
3110 /***************************************************/
3111 
3112 // https://issues.dlang.org/show_bug.cgi?id=5939
3113 // https://issues.dlang.org/show_bug.cgi?id=5940
3114 
3115 template map(fun...)
3116 {
3117     auto map(double[] r)
3118     {
3119         struct Result
3120         {
3121             this(double[] input)
3122             {
3123             }
3124         }
3125 
3126         return Result(r);
3127     }
3128 }
3129 
3130 
3131 void test139()
3132 {
3133     double[] x;
3134     alias typeof(map!"a"(x)) T;
3135     T a = void;
3136     auto b = map!"a"(x);
3137     auto c = [map!"a"(x)];
3138     T[3] d = void;
3139 }
3140 
3141 
3142 /***************************************************/
3143 // https://issues.dlang.org/show_bug.cgi?id=5966
3144 
3145 string[] foo5966(string[] a)
3146 {
3147     a[0] = a[0][0..$];
3148     return a;
3149 }
3150 
3151 enum var5966 = foo5966([""]);
3152 
3153 /***************************************************/
3154 // https://issues.dlang.org/show_bug.cgi?id=5975
3155 
3156 int foo5975(wstring replace)
3157 {
3158   wstring value = "";
3159   value ~= replace;
3160   return 1;
3161 }
3162 
3163 enum X5975 = foo5975("X"w);
3164 
3165 /***************************************************/
3166 // https://issues.dlang.org/show_bug.cgi?id=5965
3167 
3168 template mapx(fun...) if (fun.length >= 1)
3169 {
3170     int mapx(Range)(Range r)
3171     {
3172         return 1;
3173     }
3174 }
3175 
3176 void test140()
3177 {
3178    int foo(int i) { return i; }
3179 
3180    int[] arr;
3181    auto x = mapx!( (int a){return foo(a);} )(arr);
3182 }
3183 
3184 /***************************************************/
3185 
3186 void bug5976()
3187 {
3188     int[] barr;
3189     int * k;
3190     foreach (ref b; barr)
3191     {
3192         scope(failure)
3193             k = &b;
3194         k = &b;
3195     }
3196 }
3197 
3198 /***************************************************/
3199 // https://issues.dlang.org/show_bug.cgi?id=5771
3200 
3201 struct S141
3202 {
3203     this(A)(auto ref A a){}
3204 }
3205 
3206 void test141()
3207 {
3208     S141 s = S141(10);
3209 }
3210 
3211 /***************************************************/
3212 
3213 class test5498_A {}
3214 class test5498_B : test5498_A {}
3215 class test5498_C : test5498_A {}
3216 
3217 static assert(is(typeof([test5498_B.init, test5498_C.init]) == test5498_A[]));
3218 
3219 /***************************************************/
3220 // https://issues.dlang.org/show_bug.cgi?id=3688
3221 
3222 struct S142
3223 {
3224     int v;
3225     this(int n) pure { v = n; }
3226     const bool opCast(T:bool)() { return true; }
3227 }
3228 
3229 void test142()
3230 {
3231     if (int a = 1)
3232         assert(a == 1);
3233     else assert(0);
3234 
3235     if (const int a = 2)
3236         assert(a == 2);
3237     else assert(0);
3238 
3239     if (immutable int a = 3)
3240         assert(a == 3);
3241     else assert(0);
3242 
3243     if (auto s = S142(10))
3244         assert(s.v == 10);
3245     else assert(0);
3246 
3247     if (auto s = const(S142)(20))
3248         assert(s.v == 20);
3249     else assert(0);
3250 
3251     if (auto s = immutable(S142)(30))
3252         assert(s.v == 30);
3253     else assert(0);
3254 }
3255 
3256 /***************************************************/
3257 // https://issues.dlang.org/show_bug.cgi?id=6072
3258 
3259 static assert({
3260     if (int x = 5) {}
3261     return true;
3262 }());
3263 
3264 /***************************************************/
3265 // https://issues.dlang.org/show_bug.cgi?id=5959
3266 
3267 int n;
3268 
3269 void test143()
3270 {
3271     ref int f(){ return n; }            // NG
3272     f() = 1;
3273     assert(n == 1);
3274 
3275     nothrow ref int f1(){ return n; }    // OK
3276     f1() = 2;
3277     assert(n == 2);
3278 
3279     auto ref int f2(){ return n; }       // OK
3280     f2() = 3;
3281     assert(n == 3);
3282 }
3283 
3284 /***************************************************/
3285 // https://issues.dlang.org/show_bug.cgi?id=6119
3286 
3287 void startsWith(alias pred) ()   if (is(typeof(pred('c', 'd')) : bool))
3288 {
3289 }
3290 
3291 void startsWith(alias pred) ()   if (is(typeof(pred('c', "abc")) : bool))
3292 {
3293 }
3294 
3295 void test144()
3296 {
3297     startsWith!((a, b) { return a == b; })();
3298 }
3299 
3300 /***************************************************/
3301 
3302 void test145()
3303 {
3304     import core.stdc.stdio;
3305     printf("hello world 145\n");
3306 }
3307 
3308 void test146()
3309 {
3310     test1();
3311     static import core.stdc.stdio;
3312     core.stdc.stdio.printf("hello world 146\n");
3313 }
3314 
3315 /***************************************************/
3316 // https://issues.dlang.org/show_bug.cgi?id=5856
3317 
3318 struct X147
3319 {
3320     void f()       { printf("X.f mutable\n"); }
3321     void f() const { printf("X.f const\n"); }
3322 
3323     void g()()       { printf("X.g mutable\n"); }
3324     void g()() const { printf("X.g const\n"); }
3325 
3326     void opOpAssign(string op)(int n)       { printf("X+= mutable\n"); }
3327     void opOpAssign(string op)(int n) const { printf("X+= const\n"); }
3328 }
3329 
3330 void test147()
3331 {
3332     X147 xm;
3333     xm.f();     // prints "X.f mutable"
3334     xm.g();     // prints "X.g mutable"
3335     xm += 10;   // should print "X+= mutable" (1)
3336 
3337     const(X147) xc;
3338     xc.f();     // prints "X.f const"
3339     xc.g();     // prints "X.g const"
3340     xc += 10;   // should print "X+= const" (2)
3341 }
3342 
3343 
3344 /***************************************************/
3345 
3346 void test3559()
3347 {
3348     static class A
3349     {
3350         int foo(int a)   { return 0; }
3351         int foo(float a) { return 1; }
3352 
3353         int bar(float a) { return 1; }
3354         int bar(int a) { return 0; }
3355     }
3356 
3357     static class B : A
3358     {
3359         override int foo(float a) { return 2; }
3360         alias A.foo foo;
3361 
3362         alias A.bar bar;
3363         override int bar(float a) { return 2; }
3364     }
3365 
3366     {
3367         auto x = new A;
3368         auto f1 = cast(int delegate(int))&x.foo;
3369         auto f2 = cast(int delegate(float))&x.foo;
3370         int delegate(int) f3 = &x.foo;
3371         int delegate(float) f4 = &x.foo;
3372 
3373         assert(f1(0) == 0);
3374         assert(f2(0) == 1);
3375         assert(f3(0) == 0);
3376         assert(f4(0) == 1);
3377     }
3378 
3379     {
3380         auto x = new B;
3381         auto f1 = cast(int delegate(int))&x.foo;
3382         auto f2 = cast(int delegate(float))&x.foo;
3383         int delegate(int) f3 = &x.foo;
3384         int delegate(float) f4 = &x.foo;
3385 
3386         assert(f1(0) == 0);
3387         assert(f2(0) == 2);
3388         assert(f3(0) == 0);
3389         assert(f4(0) == 2);
3390     }
3391 
3392     {
3393         auto x = new A;
3394         auto f1 = cast(int delegate(int))&x.bar;
3395         auto f2 = cast(int delegate(float))&x.bar;
3396         int delegate(int) f3 = &x.bar;
3397         int delegate(float) f4 = &x.bar;
3398 
3399         assert(f1(0) == 0);
3400         assert(f2(0) == 1);
3401         assert(f3(0) == 0);
3402         assert(f4(0) == 1);
3403     }
3404 
3405     {
3406         auto x = new B;
3407         auto f1 = cast(int delegate(int))&x.bar;
3408         auto f2 = cast(int delegate(float))&x.bar;
3409         int delegate(int) f3 = &x.bar;
3410         int delegate(float) f4 = &x.bar;
3411 
3412         assert(f1(0) == 0);
3413         assert(f2(0) == 2);
3414         assert(f3(0) == 0);
3415         assert(f4(0) == 2);
3416     }
3417 }
3418 
3419 /***************************************************/
3420 
3421 extern(C++)
3422 class C13182
3423 {
3424 }
3425 
3426 void test13182()
3427 {
3428     scope C13182 c = new C13182();
3429 }
3430 
3431 /***************************************************/
3432 // https://issues.dlang.org/show_bug.cgi?id=5897
3433 
3434 struct A148{ int n; }
3435 struct B148{
3436     int n, m;
3437     this(A148 a){ n = a.n, m = a.n*2; }
3438 }
3439 
3440 struct C148{
3441     int n, m;
3442     static C148 opCall(A148 a)
3443     {
3444         C148 b;
3445         b.n = a.n, b.m = a.n*2;
3446         return b;
3447     }
3448 }
3449 
3450 void test148()
3451 {
3452     auto a = A148(10);
3453     auto b = cast(B148)a;
3454     assert(b.n == 10 && b.m == 20);
3455     auto c = cast(C148)a;
3456     assert(c.n == 10 && c.m == 20);
3457 }
3458 
3459 /***************************************************/
3460 // https://issues.dlang.org/show_bug.cgi?id=4969
3461 
3462 class MyException : Exception
3463 {
3464     this()
3465     {
3466         super("An exception!");
3467     }
3468 }
3469 
3470 void throwAway()
3471 {
3472     throw new MyException;
3473 }
3474 
3475 void cantthrow() nothrow
3476 {
3477     try
3478         throwAway();
3479     catch(MyException me)
3480         assert(0);
3481     catch(Exception e)
3482         assert(0);
3483 }
3484 
3485 /***************************************************/
3486 // https://issues.dlang.org/show_bug.cgi?id=2356
3487 
3488 void test2356()
3489 {
3490     int[3] x = [1,2,3];
3491     printf("x[] = [%d %d %d]\n", x[0], x[1], x[2]);
3492     assert(x[0] == 1 && x[1] == 2 && x[2] == 3);
3493 
3494     struct S
3495     {
3496         static int pblit;
3497         int n;
3498         this(this) { ++pblit; printf("postblit: %d\n", n); }
3499     }
3500     S s2 = S(2);
3501     S[3] s = [S(1), s2, S(3)];
3502     assert(s[0].n == 1 && s[1].n == 2 && s[2].n == 3);
3503     printf("s[].n = [%d %d %d]\n", s[0].n, s[1].n, s[2].n);
3504     assert(S.pblit == 1);
3505 
3506     ubyte[1024] v;
3507     v = typeof(v).init;
3508     printf("v[] = [%d %d %d, ..., %d]\n", v[0], v[1], v[2], v[$-1]);
3509     foreach (ref a; v) assert(a == 0);
3510 
3511     int n = 5;
3512     int[3] y = [n, n, n];
3513     printf("y[] = [%d %d %d]\n", y[0], y[1], y[2]);
3514     assert(y[0] == 5 && y[1] == 5 && y[2] == 5);
3515 
3516     S[3] z = [s2, s2, s2];
3517     assert(z[0].n == 2 && z[1].n == 2 && z[2].n == 2);
3518     printf("z[].n = [%d %d %d]\n", z[0].n, z[1].n, z[2].n);
3519     assert(S.pblit == 1 + 3);
3520 
3521     int[0] nsa0 = [];
3522     void[0] vsa0 = [];
3523 
3524     void foo(T)(T){}
3525     foo(vsa0);
3526 
3527     ref int[0] bar() { static int[1] sa; return *cast(int[0]*)&sa; }
3528     bar() = [];
3529 }
3530 
3531 /***************************************************/
3532 // https://issues.dlang.org/show_bug.cgi?id=13652
3533 
3534 void test13652()
3535 {
3536     // reduced case
3537     uint[9][5] arr =
3538         [[0, 0, 0,  0, 1, 5,  8, 0, 7],
3539          [0, 3, 8,  0, 2, 0,  0, 6, 0],
3540          [0, 0, 7,  0, 6, 8,  9, 4, 0],
3541          [0, 0, 0,  0, 0, 1,  2, 9, 0],
3542          [9, 7, 0,  0, 0, 0,  0, 8, 3]];
3543     assert(arr[0][0] == 0 && arr[0][1] == 0 && arr[0][2] == 0 &&
3544            arr[0][3] == 0 && arr[0][4] == 1 && arr[0][5] == 5 &&
3545            arr[0][6] == 8 && arr[0][7] == 0 && arr[0][8] == 7);
3546     assert(arr[1][0] == 0 && arr[1][1] == 3 && arr[1][2] == 8 &&
3547            arr[1][3] == 0 && arr[1][4] == 2 && arr[1][5] == 0 &&
3548            arr[1][6] == 0 && arr[1][7] == 6 && arr[1][8] == 0);
3549     assert(arr[2][0] == 0 && arr[2][1] == 0 && arr[2][2] == 7 &&
3550            arr[2][3] == 0 && arr[2][4] == 6 && arr[2][5] == 8 &&
3551            arr[2][6] == 9 && arr[2][7] == 4 && arr[2][8] == 0);
3552     assert(arr[3][0] == 0 && arr[3][1] == 0 && arr[3][2] == 0 &&
3553            arr[3][3] == 0 && arr[3][4] == 0 && arr[3][5] == 1 &&
3554            arr[3][6] == 2 && arr[3][7] == 9 && arr[3][8] == 0);
3555     assert(arr[4][0] == 9 && arr[4][1] == 7 && arr[4][2] == 0 &&
3556            arr[4][3] == 0 && arr[4][4] == 0 && arr[4][5] == 0 &&
3557            arr[4][6] == 0 && arr[4][7] == 8 && arr[4][8] == 3);
3558 
3559     // original case
3560     uint[9][9] tbl =
3561         [[0, 0, 0,  0, 1, 5,  8, 0, 7],
3562          [0, 3, 8,  0, 2, 0,  0, 6, 0],
3563          [0, 0, 7,  0, 6, 8,  9, 4, 0],
3564          [0, 0, 0,  0, 0, 1,  2, 9, 0],
3565          [9, 7, 0,  0, 0, 0,  0, 8, 3],
3566          [0, 2, 1,  6, 0, 0,  0, 0, 0],
3567          [0, 6, 9,  5, 4, 0,  3, 0, 0],
3568          [0, 4, 0,  0, 8, 0,  6, 5, 0],
3569          [2, 0, 5,  9, 3, 0,  0, 0, 0]];
3570     assert(tbl[0][0] == 0 && tbl[0][1] == 0 && tbl[0][2] == 0 &&
3571            tbl[0][3] == 0 && tbl[0][4] == 1 && tbl[0][5] == 5 &&
3572            tbl[0][6] == 8 && tbl[0][7] == 0 && tbl[0][8] == 7);
3573     assert(tbl[1][0] == 0 && tbl[1][1] == 3 && tbl[1][2] == 8 &&
3574            tbl[1][3] == 0 && tbl[1][4] == 2 && tbl[1][5] == 0 &&
3575            tbl[1][6] == 0 && tbl[1][7] == 6 && tbl[1][8] == 0);
3576     assert(tbl[2][0] == 0 && tbl[2][1] == 0 && tbl[2][2] == 7 &&
3577            tbl[2][3] == 0 && tbl[2][4] == 6 && tbl[2][5] == 8 &&
3578            tbl[2][6] == 9 && tbl[2][7] == 4 && tbl[2][8] == 0);
3579     assert(tbl[3][0] == 0 && tbl[3][1] == 0 && tbl[3][2] == 0 &&
3580            tbl[3][3] == 0 && tbl[3][4] == 0 && tbl[3][5] == 1 &&
3581            tbl[3][6] == 2 && tbl[3][7] == 9 && tbl[3][8] == 0);
3582     assert(tbl[4][0] == 9 && tbl[4][1] == 7 && tbl[4][2] == 0 &&
3583            tbl[4][3] == 0 && tbl[4][4] == 0 && tbl[4][5] == 0 &&
3584            tbl[4][6] == 0 && tbl[4][7] == 8 && tbl[4][8] == 3);
3585     assert(tbl[5][0] == 0 && tbl[5][1] == 2 && tbl[5][2] == 1 &&
3586            tbl[5][3] == 6 && tbl[5][4] == 0 && tbl[5][5] == 0 &&
3587            tbl[5][6] == 0 && tbl[5][7] == 0 && tbl[5][8] == 0);
3588     assert(tbl[6][0] == 0 && tbl[6][1] == 6 && tbl[6][2] == 9 &&
3589            tbl[6][3] == 5 && tbl[6][4] == 4 && tbl[6][5] == 0 &&
3590            tbl[6][6] == 3 && tbl[6][7] == 0 && tbl[6][8] == 0);
3591     assert(tbl[7][0] == 0 && tbl[7][1] == 4 && tbl[7][2] == 0 &&
3592            tbl[7][3] == 0 && tbl[7][4] == 8 && tbl[7][5] == 0 &&
3593            tbl[7][6] == 6 && tbl[7][7] == 5 && tbl[7][8] == 0);
3594     assert(tbl[8][0] == 2 && tbl[8][1] == 0 && tbl[8][2] == 5 &&
3595            tbl[8][3] == 9 && tbl[8][4] == 3 && tbl[8][5] == 0 &&
3596            tbl[8][6] == 0 && tbl[8][6] == 0 && tbl[8][8] == 0);
3597 }
3598 
3599 /***************************************************/
3600 // https://issues.dlang.org/show_bug.cgi?id=11238
3601 
3602 void test11238()
3603 {
3604     int[2] m;
3605     m[0] = 4,m[1] = 6;
3606     //printf("%d,%d\n", m[0], m[1]);
3607     assert(m[0] == 4 && m[1] == 6);
3608 
3609     m = [m[1], m[0]];   // swap
3610     assert(m[0] == 6 && m[1] == 4);
3611     //printf("%d,%d\n", m[0], m[1]);
3612 
3613     m = [m[1], m[0]];   // swap
3614     //printf("%d,%d\n", m[0], m[1]);
3615     assert(m[0] == 4 && m[1] == 6);
3616 }
3617 
3618 /***************************************************/
3619 
3620 void test11805()
3621 {
3622     int i;
3623 
3624     i = 47;
3625     i = 1 && i;
3626     assert(i == 1);
3627     i = 0 || i;
3628     assert(i == 1);
3629 }
3630 
3631 /***************************************************/
3632 
3633 class A2540
3634 {
3635     int a;
3636     int foo() { return 0; }
3637     alias int X;
3638 }
3639 
3640 class B2540 : A2540
3641 {
3642     int b;
3643     override typeof(super).X foo() { return 1; }
3644 
3645     alias typeof(this) athis;
3646     alias typeof(this).b thisb;
3647     alias typeof(super).a supera;
3648     alias typeof(super).foo superfoo;
3649     alias typeof(this).foo thisfoo;
3650 }
3651 
3652 struct X2540
3653 {
3654     alias typeof(this) athis;
3655 }
3656 
3657 void test2540()
3658 {
3659     auto x = X2540.athis.init;
3660     static assert(is(typeof(x) == X2540));
3661 
3662     B2540 b = new B2540();
3663 
3664     assert(&b.a == &b.supera);
3665     assert(&b.b == &b.thisb);
3666     assert(b.thisfoo() == 1);
3667 }
3668 
3669 /***************************************************/
3670 
3671 class B14348
3672 {
3673     int foo() { return 0; }
3674 }
3675 
3676 class C14348 : B14348
3677 {
3678     override int foo() { return 1; }
3679 
3680     alias superfoo = typeof(super).foo;
3681     alias thisfoo = typeof(this).foo;
3682 }
3683 
3684 B14348 test14348()
3685 {
3686     alias foo = typeof(return).foo;  // currently doesn't work.
3687     assert(&B14348.foo is &C14348.superfoo);
3688     assert(&C14348.foo is &C14348.thisfoo);
3689     return null;
3690 }
3691 
3692 /***************************************************/
3693 // https://issues.dlang.org/show_bug.cgi?id=7295
3694 
3695 struct S7295
3696 {
3697     int member;
3698     @property ref int refCountedPayload() return { return member; }
3699     alias refCountedPayload this;
3700 }
3701 
3702 void foo7295(S)(immutable S t, int qq) pure { }
3703 void foo7295(S)(S s) pure { }
3704 
3705 void bar7295() pure
3706 {
3707     S7295 b;
3708     foo7295(b);
3709 }
3710 
3711 /***************************************************/
3712 // https://issues.dlang.org/show_bug.cgi?id=5659
3713 
3714 void test149()
3715 {
3716     char a;
3717     immutable(char) b;
3718 
3719     static assert(is(typeof(true ? a : b) == const(char)));
3720     static assert(is(typeof([a, b][0]) == const(char)));
3721 }
3722 
3723 
3724 /***************************************************/
3725 // https://issues.dlang.org/show_bug.cgi?id=1373
3726 
3727 void func1373a(){}
3728 
3729 static assert(typeof(func1373a).stringof == "void()");
3730 static assert(typeof(func1373a).mangleof == "FZv");
3731 static assert(!__traits(compiles, typeof(func1373a).alignof));
3732 static assert(!__traits(compiles, typeof(func1373a).init));
3733 static assert(!__traits(compiles, typeof(func1373a).offsetof));
3734 
3735 void func1373b(int n){}
3736 
3737 static assert(typeof(func1373b).stringof == "void(int n)");
3738 static assert(typeof(func1373b).mangleof == "FiZv");
3739 static assert(!__traits(compiles, typeof(func1373b).alignof));
3740 static assert(!__traits(compiles, typeof(func1373b).init));
3741 static assert(!__traits(compiles, typeof(func1373b).offsetof));
3742 
3743 /***************************************************/
3744 
3745 void bar150(T)(T n) {  }
3746 
3747 @safe void test150()
3748 {
3749     bar150(1);
3750 }
3751 
3752 /***************************************************/
3753 
3754 void test5785()
3755 {
3756     static struct x { static int y; }
3757     assert(x.y !is 1);
3758     assert(x.y !in [1:0]);
3759 }
3760 
3761 /***************************************************/
3762 
3763 void bar151(T)(T n) {  }
3764 
3765 nothrow void test151()
3766 {
3767     bar151(1);
3768 }
3769 
3770 /***************************************************/
3771 
3772 @property int coo() { return 1; }
3773 @property auto doo(int i) { return i; }
3774 
3775 @property int eoo() { return 1; }
3776 @property auto ref hoo(int i) { return i; }
3777 
3778 // https://issues.dlang.org/show_bug.cgi?id=3359
3779 
3780 int goo(int i) pure { return i; }
3781 auto ioo(int i) pure { return i; }
3782 auto ref boo(int i) pure nothrow { return i; }
3783 
3784 class A152 {
3785     auto hoo(int i) pure  { return i; }
3786     const boo(int i) nothrow { return i; }
3787     auto coo(int i) const { return i; }
3788     auto doo(int i) immutable { return i; }
3789     auto eoo(int i) shared { return i; }
3790 }
3791 
3792 // https://issues.dlang.org/show_bug.cgi?id=4706
3793 
3794 struct Foo152(T) {
3795     @property auto ref front() {
3796         return T.init;
3797     }
3798 
3799     @property void front(T num) {}
3800 }
3801 
3802 void test152() {
3803     Foo152!int foo;
3804     auto a = foo.front;
3805     foo.front = 2;
3806 }
3807 
3808 /***************************************************/
3809 // https://issues.dlang.org/show_bug.cgi?id=6733
3810 
3811 void bug6733(int a, int b) pure nothrow { }
3812 void test6733() {
3813    int z = 1;
3814    bug6733(z++, z++);
3815    assert(z==3);
3816 }
3817 
3818 /***************************************************/
3819 // https://issues.dlang.org/show_bug.cgi?id=3799
3820 
3821 void test153()
3822 {
3823     void bar()
3824     {
3825     }
3826 
3827     static assert(!__traits(isStaticFunction, bar));
3828 }
3829 
3830 /***************************************************/
3831 // https://issues.dlang.org/show_bug.cgi?id=3632
3832 
3833 
3834 void test154() {
3835     float f;
3836     assert(f is float.init);
3837     double d;
3838     assert(d is double.init);
3839     real r;
3840     assert(r is real.init);
3841 
3842     assert(float.nan is float.nan);
3843     assert(double.nan is double.nan);
3844     assert(real.nan is real.nan);
3845 }
3846 
3847 /***************************************************/
3848 
3849 void test6545()
3850 {
3851     static int[] func()
3852     {
3853         auto a = [1, 2, 3];
3854         auto b = [2, 3, 4];
3855         auto c = [3, 4, 5];
3856 
3857         a[] = b[] + c[];
3858 
3859         return a;
3860     }
3861 
3862     auto a = func();
3863     enum b = func();
3864     assert(a == b);
3865 }
3866 
3867 /***************************************************/
3868 // https://issues.dlang.org/show_bug.cgi?id=3147
3869 
3870 
3871 void test155()
3872 {
3873     byte b = 1;
3874     short s;
3875     int i;
3876     long l;
3877 
3878     s = b + b;
3879     b = s % b;
3880     s = s >> b;
3881     b = 1;
3882     b = i % b;
3883     b = b >> i;
3884 }
3885 
3886 /***************************************************/
3887 // https://issues.dlang.org/show_bug.cgi?id=2486
3888 
3889 void test2486()
3890 {
3891     void foo(ref int[] arr) {}
3892 
3893     int[] arr = [1,2,3];
3894     foo(arr);   //OK
3895     static assert(__traits(compiles, foo(arr[1..2])));
3896 
3897     struct S
3898     {
3899         int[] a;
3900         auto ref opSlice(){ return a[]; }  // line 4
3901     }
3902     S s;
3903     s[];
3904     // opSlice should return rvalue
3905     static assert(is(typeof(&S.opSlice) == int[] function() pure nothrow @nogc @safe));
3906     static assert(__traits(compiles, foo(s[])));
3907 }
3908 
3909 /***************************************************/
3910 
3911 extern(C++) class C15080
3912 {
3913     uint x = 1;
3914     uint y = 2;
3915 }
3916 
3917 __gshared c15080 = new C15080();
3918 
3919 void test15080()
3920 {
3921     assert(c15080.x == 1);
3922     assert(c15080.y == 2);
3923 }
3924 
3925 /***************************************************/
3926 // https://issues.dlang.org/show_bug.cgi?id=2521
3927 
3928 immutable int val = 23;
3929 const int val2 = 23;
3930 
3931 ref immutable(int) func2521_() {
3932     return val;
3933 }
3934 ref immutable(int) func2521_2() {
3935     return *&val;
3936 }
3937 ref immutable(int) func2521_3() {
3938     return func2521_;
3939 }
3940 ref const(int) func2521_4() {
3941     return val2;
3942 }
3943 ref const(int) func2521_5() {
3944     return val;
3945 }
3946 auto ref func2521_6() {
3947     return val;
3948 }
3949 ref func2521_7() {
3950     return val;
3951 }
3952 
3953 /***************************************************/
3954 
3955 void test5554()
3956 {
3957     class MA { }
3958     class MB : MA { }
3959     class MC : MB { }
3960 
3961     class A { abstract MA foo(); }
3962     interface I { MB foo(); }
3963     class B : A
3964     {
3965         override MC foo() { return null; }
3966     }
3967     class C : B, I
3968     {
3969         override MC foo() { return null; }
3970     }
3971 }
3972 
3973 /***************************************************/
3974 // https://issues.dlang.org/show_bug.cgi?id=5962
3975 
3976 struct S156
3977 {
3978           auto g()(){ return 1; }
3979     const auto g()(){ return 2; }
3980 }
3981 
3982 void test156()
3983 {
3984     auto ms = S156();
3985     assert(ms.g() == 1);
3986     auto cs = const(S156)();
3987     assert(cs.g() == 2);
3988 }
3989 
3990 /***************************************************/
3991 
3992 void test10724()
3993 {
3994     const(char)* s = "abc"[0..$-1];
3995     assert(s[2] == '\0');
3996 }
3997 
3998 /***************************************************/
3999 
4000 void test6708(const ref int y)
4001 {
4002     immutable int x;
4003     test6708(x);
4004 }
4005 
4006 /***************************************************/
4007 // https://issues.dlang.org/show_bug.cgi?id=4258
4008 
4009 struct Vec4258 {
4010     Vec4258 opOpAssign(string Op)(auto ref Vec4258 other) if (Op == "+") {
4011         return this;
4012     }
4013     Vec4258 opBinary(string Op:"+")(Vec4258 other) {
4014         Vec4258 result;
4015         return result += other;
4016     }
4017 }
4018 void test4258() {
4019     Vec4258 v;
4020     v += Vec4258() + Vec4258(); // line 12
4021 }
4022 
4023 // regression fix test
4024 
4025 struct Foo4258 {
4026     // binary ++/--
4027     int opPostInc()() if (false) { return 0; }
4028 
4029     // binary 1st
4030     int opAdd(R)(R rhs) if (false) { return 0; }
4031     int opAdd_r(R)(R rhs) if (false) { return 0; }
4032 
4033     // compare
4034     int opCmp(R)(R rhs) if (false) { return 0; }
4035 
4036     // binary-op assign
4037     int opAddAssign(R)(R rhs) if (false) { return 0; }
4038 }
4039 struct Bar4258 {
4040     // binary commutive 1
4041     int opAdd_r(R)(R rhs) if (false) { return 0; }
4042 
4043     // binary-op assign
4044     int opOpAssign(string op, R)(R rhs) if (false) { return 0; }
4045 }
4046 struct Baz4258 {
4047     // binary commutive 2
4048     int opAdd(R)(R rhs) if (false) { return 0; }
4049 }
4050 static assert(!is(typeof(Foo4258.init++)));
4051 static assert(!is(typeof(Foo4258.init + 1)));
4052 static assert(!is(typeof(1 + Foo4258.init)));
4053 static assert(!is(typeof(Foo4258.init < Foo4258.init)));
4054 static assert(!is(typeof(Foo4258.init += 1)));
4055 static assert(!is(typeof(Bar4258.init + 1)));
4056 static assert(!is(typeof(Bar4258.init += 1)));
4057 static assert(!is(typeof(1 + Baz4258.init)));
4058 
4059 /***************************************************/
4060 // https://issues.dlang.org/show_bug.cgi?id=4539
4061 
4062 void test4539()
4063 {
4064     static assert(!__traits(compiles, "hello" = "red"));
4065 
4066     void foo1(ref string s){}
4067     void foo2(ref const char[10] s){}
4068     void foo3(ref char[5] s){}
4069 
4070     void foo4(ref const char[5] s)
4071     {
4072         assert(s[0] == 'h');
4073         assert(s[4] == 'o');
4074     }
4075     void foo5(ref const ubyte[5] s)
4076     {
4077         assert(s[0] == 0xc3);
4078         assert(s[4] == 0x61);
4079     }
4080 
4081     static assert(__traits(compiles, foo1("hello")));
4082     static assert(!__traits(compiles, foo2("hello")));
4083     static assert(!__traits(compiles, foo3("hello")));
4084 
4085     // same as test68, 69, 70
4086     foo4("hello");
4087     foo5(cast(ubyte[5])"\xc3\xfc\xd3\xd7\x61");
4088 
4089     //import std.conv;
4090     //static assert(!__traits(compiles, parse!int("10") == 10));
4091 }
4092 
4093 /***************************************************/
4094 // https://issues.dlang.org/show_bug.cgi?id=1471
4095 
4096 void test1471()
4097 {
4098     int n;
4099     string bar = "BOOM"[n..$-1];
4100     assert(bar == "BOO");
4101 }
4102 
4103 /***************************************************/
4104 
4105 deprecated @disable int bug6389;
4106 static assert(!is(typeof(bug6389 = bug6389)));
4107 
4108 /***************************************************/
4109 
4110 void test4963()
4111 {
4112     struct Value {
4113         byte a;
4114     }
4115     Value single()
4116     {
4117         return Value();
4118     }
4119 
4120     Value[] list;
4121     auto x = single() ~ list;
4122 }
4123 
4124 /***************************************************/
4125 
4126 pure int test4031()
4127 {
4128     static const int x = 8;
4129     return x;
4130 }
4131 
4132 /***************************************************/
4133 // https://issues.dlang.org/show_bug.cgi?id=5437
4134 
4135 template EnumMembers5437(E)
4136 {
4137     template TypeTuple(T...){ alias T TypeTuple; }
4138 
4139     alias TypeTuple!("A", "B") EnumMembers5437;
4140 }
4141 template IntValue5437()
4142 {
4143     int IntValue5437 = 10;
4144 }
4145 
4146 void test5437()
4147 {
4148     enum Foo { A, B }
4149     alias EnumMembers5437!Foo members;      // OK
4150     enum n1 = members.length;               // OK
4151     enum n2 = (EnumMembers5437!Foo).length; // NG, type -> symbol
4152 
4153     enum s1 = IntValue5437!().sizeof;       // OK
4154     enum s2 = (IntValue5437!()).sizeof;     // NG, type -> expression
4155 }
4156 
4157 /***************************************************/
4158 // https://issues.dlang.org/show_bug.cgi?id=1962
4159 
4160 
4161 void test1962()
4162 {
4163     class C { abstract void x(); }
4164     assert(C.classinfo.create() is null);
4165 }
4166 
4167 /***************************************************/
4168 // https://issues.dlang.org/show_bug.cgi?id=6228
4169 
4170 void test6228()
4171 {
4172     int val;
4173     const(int)* ptr = &val;
4174     const(int)  temp;
4175     auto x = (*ptr) ^^ temp;
4176 }
4177 
4178 /***************************************************/
4179 
4180 int test7544()
4181 {
4182     try { throw new Exception(""); }
4183     catch (Exception e) static assert(1);
4184     return 1;
4185 }
4186 
4187 static assert(test7544());
4188 
4189 /***************************************************/
4190 
4191 struct S6230 {
4192     int p;
4193     int q() const pure {
4194         return p;
4195     }
4196     void r() pure {
4197         p = 231;
4198     }
4199 }
4200 class C6230 {
4201     int p;
4202     int q() const pure {
4203         return p;
4204     }
4205     void r() pure {
4206         p = 552;
4207     }
4208 }
4209 int q6230(ref const S6230 s) pure {    // <-- Currently OK
4210     return s.p;
4211 }
4212 int q6230(ref const C6230 c) pure {    // <-- Currently OK
4213     return c.p;
4214 }
4215 void r6230(ref S6230 s) pure {
4216     s.p = 244;
4217 }
4218 void r6230(ref C6230 c) pure {
4219     c.p = 156;
4220 }
4221 bool test6230pure() pure {
4222     auto s = S6230(4);
4223     assert(s.p == 4);
4224     assert(q6230(s) == 4);
4225     assert(s.q == 4);
4226 
4227     auto c = new C6230;
4228     c.p = 6;
4229     assert(q6230(c) == 6);
4230     assert(c.q == 6);
4231 
4232     r6230(s);
4233     assert(s.p == 244);
4234     s.r();
4235     assert(s.p == 231);
4236 
4237     r6230(c);
4238     assert(c.p == 156);
4239     c.r();
4240     assert(c.p == 552);
4241 
4242     return true;
4243 }
4244 void test6230() {
4245     assert(test6230pure());
4246 }
4247 
4248 /***************************************************/
4249 
4250 void test6264()
4251 {
4252     struct S { auto opSlice() { return this; } }
4253     int[] a;
4254     S s;
4255     static assert(!is(typeof(a[] = s[])));
4256     int*[] b;
4257     static assert(is(typeof(b[] = [new immutable(int)])));
4258     char[] c = new char[](5);
4259     c[] = "hello";
4260 }
4261 
4262 /***************************************************/
4263 // https://issues.dlang.org/show_bug.cgi?id=5046
4264 
4265 void test5046()
4266 {
4267     auto va = S5046!("", int)();
4268     auto vb = makeS5046!("", int)();
4269 }
4270 
4271 struct S5046(alias p, T)
4272 {
4273     T s;
4274     T fun() { return s; }   // (10)
4275 }
4276 
4277 S5046!(p, T) makeS5046(alias p, T)()
4278 {
4279     return typeof(return)();
4280 }
4281 
4282 /***************************************************/
4283 // https://issues.dlang.org/show_bug.cgi?id=6335
4284 
4285 struct S6335
4286 {
4287     const int value;
4288     this()(int n){ value = n; }
4289 }
4290 void test6335()
4291 {
4292     S6335 s = S6335(10);
4293 }
4294 
4295 /***************************************************/
4296 
4297 struct S6295(int N) {
4298     int[N] x;
4299     const nothrow pure @safe f() { return x.length; }
4300 }
4301 
4302 void test6295() {
4303     auto bar(T: S6295!(N), int N)(T x) {
4304         return x.f();
4305     }
4306     S6295!4 x;
4307     assert(bar(x) == 4);
4308 }
4309 
4310 /***************************************************/
4311 
4312 template TT4536(T...) { alias T TT4536; }
4313 
4314 void test4536()
4315 {
4316     auto x = TT4536!(int, long, [1, 2]).init;
4317     assert(x[0] is int.init);
4318     assert(x[1] is long.init);
4319     assert(x[2] is [1, 2].init);
4320 }
4321 
4322 /***************************************************/
4323 
4324 struct S6284 {
4325     int a;
4326 }
4327 class C6284 {
4328     int a;
4329 }
4330 pure int bug6284a() {
4331     S6284 s = {4};
4332     auto b = s.a;   // ok
4333     with (s) {
4334         b += a;     // should be ok.
4335     }
4336     return b;
4337 }
4338 pure int bug6284b() {
4339     auto s = new S6284;
4340     s.a = 4;
4341     auto b = s.a;
4342     with (*s) {
4343         b += a;
4344     }
4345     return b;
4346 }
4347 pure int bug6284c() {
4348     auto s = new C6284;
4349     s.a = 4;
4350     auto b = s.a;
4351     with (s) {
4352         b += a;
4353     }
4354     return b;
4355 }
4356 void test6284() {
4357     assert(bug6284a() == 8);
4358     assert(bug6284b() == 8);
4359     assert(bug6284c() == 8);
4360 }
4361 
4362 /***************************************************/
4363 
4364 class C6293 {
4365     C6293 token;
4366 }
4367 void f6293(in C6293[] a) pure {
4368     auto x0 = a[0].token;
4369     assert(x0 is a[0].token.token.token);
4370     assert(x0 is (&x0).token);
4371     auto p1 = &x0 + 1;
4372     assert(x0 is (p1 - 1).token);
4373     int c = 0;
4374     assert(x0 is a[c].token);
4375 }
4376 void test6293() {
4377     auto x = new C6293;
4378     x.token = x;
4379     f6293([x]);
4380 }
4381 
4382 /***************************************************/
4383 // https://issues.dlang.org/show_bug.cgi?id=3733
4384 
4385 class C3733
4386 {
4387     int foo()        { return 1; }
4388     int foo() shared { return 2; }
4389 
4390     int bar()        { return foo(); }
4391 }
4392 void test3733()
4393 {
4394     auto c = new C3733();
4395     assert(c.bar() == 1);
4396 }
4397 
4398 /***************************************************/
4399 // https://issues.dlang.org/show_bug.cgi?id=4392
4400 
4401 class C4392
4402 {
4403     int foo() const { return 1; }
4404     int foo()       { return 2; }
4405 
4406     int bar() const { return foo(); }
4407 }
4408 void test4392()
4409 {
4410     auto c = new C4392();
4411     assert(c.bar() == 1);
4412 }
4413 
4414 /***************************************************/
4415 // https://issues.dlang.org/show_bug.cgi?id=6220
4416 
4417 void test6220() {
4418     struct Foobar { real x; real y; real z;}
4419     switch("x") {
4420         foreach(i,member; __traits(allMembers, Foobar)) {
4421             case member : break;
4422         }
4423     default : break;
4424     }
4425 }
4426 
4427 /***************************************************/
4428 // https://issues.dlang.org/show_bug.cgi?id=5799
4429 
4430 void test5799()
4431 {
4432     int a;
4433     int *u = &(a ? a : (a ? a : a));
4434     assert(u == &a);
4435 }
4436 
4437 /***************************************************/
4438 // https://issues.dlang.org/show_bug.cgi?id=6529
4439 
4440 enum Foo6529 : char { A='a' }
4441 ref const(Foo6529) func6529(const(Foo6529)[] arr){ return arr[0]; }
4442 
4443 /***************************************************/
4444 
4445 void test783()
4446 {
4447     const arr = [ 1,2,3 ];
4448     const i = 2;
4449     auto jhk = new int[arr[i]]; // "need size of rightmost array, not type arr[i]"
4450 }
4451 
4452 /***************************************************/
4453 
4454 template X157(alias x)
4455 {
4456     alias x X157;
4457 }
4458 
4459 template Parent(alias foo)
4460 {
4461     alias X157!(__traits(parent, foo)) Parent;
4462 }
4463 
4464 template ParameterTypeTuple(alias foo)
4465 {
4466     static if (is(typeof(foo) P == function))
4467         alias P ParameterTypeTuple;
4468     else
4469         static assert(0, "argument has no parameters");
4470 }
4471 
4472 template Mfp(alias foo)
4473 {
4474     auto Mfp = function(Parent!foo self, ParameterTypeTuple!foo i) { return self.foo(i); };
4475 }
4476 
4477 class C157 {
4478  int a = 3;
4479  int foo(int i, int y) { return i + a + y; }
4480 }
4481 
4482 void test157()
4483 {
4484     auto c = new C157();
4485     auto mfp = Mfp!(C157.foo);
4486     auto i = mfp(c, 1, 7);
4487     assert(i == 11);
4488 }
4489 
4490 /***************************************************/
4491 // https://issues.dlang.org/show_bug.cgi?id=6473
4492 
4493 struct Eins6473
4494 {
4495     ~this() {}
4496 }
4497 
4498 struct Zwei6473
4499 {
4500     void build(Eins6473 devices = Eins6473())
4501     {
4502     }
4503 }
4504 
4505 void build(Eins6473 devices = Eins6473())
4506 {}
4507 
4508 void test6473()
4509 {
4510     void build(Eins6473 devices = Eins6473())
4511     {}
4512 }
4513 
4514 /***************************************************/
4515 
4516 uint rol11417(uint n)(in uint x)
4517 {
4518     return x << n | x >> 32 - n;
4519 }
4520 
4521 uint ror11417(uint n)(in uint x)
4522 {
4523     return x >> n | x << 32 - n;
4524 }
4525 
4526 void test11417()
4527 {
4528     assert(rol11417!1(0x8000_0000) == 0x1);
4529     assert(ror11417!1(0x1) == 0x8000_0000);
4530 }
4531 
4532 /***************************************************/
4533 
4534 void test6578()
4535 {
4536     static struct Foo
4537     {
4538         this(int x) pure {}
4539     }
4540     auto f1 = new const(Foo)(1);
4541     auto f2 = new immutable(Foo)(1);
4542     auto f3 = new shared(Foo)(1);
4543     auto f4 = const(Foo)(1);
4544     auto f5 = immutable(Foo)(1);
4545     auto f6 = shared(Foo)(1);
4546     static assert(is(typeof(f1) == const(Foo)*));
4547     static assert(is(typeof(f2) == immutable(Foo)*));
4548     static assert(is(typeof(f3) == shared(Foo)*));
4549     static assert(is(typeof(f4) == const(Foo)));
4550     static assert(is(typeof(f5) == immutable(Foo)));
4551     static assert(is(typeof(f6) == shared(Foo)));
4552 
4553     static struct Bar
4554     {
4555         this(int x) const pure {}
4556     }
4557     auto g1 = new const(Bar)(1);
4558     auto g2 = new immutable(Bar)(1);
4559     auto g3 = new shared(Bar)(1);
4560     auto g4 = const(Bar)(1);
4561     auto g5 = immutable(Bar)(1);
4562     auto g6 = shared(Bar)(1);
4563     static assert(is(typeof(g1) == const(Bar)*));
4564     static assert(is(typeof(g2) == immutable(Bar)*));
4565     static assert(is(typeof(g3) == shared(Bar)*));
4566     static assert(is(typeof(g4) == const(Bar)));
4567     static assert(is(typeof(g5) == immutable(Bar)));
4568     static assert(is(typeof(g6) == shared(Bar)));
4569 
4570     static struct Baz
4571     {
4572         this()(int x) const pure {}
4573     }
4574     auto h1 = new const(Baz)(1);
4575     auto h2 = new immutable(Baz)(1);
4576     auto h3 = new shared(const(Baz))(1);
4577     auto h4 = const(Baz)(1);
4578     auto h5 = immutable(Baz)(1);
4579     auto h6 = shared(const(Baz))(1);
4580     static assert(is(typeof(h1) == const(Baz)*));
4581     static assert(is(typeof(h2) == immutable(Baz)*));
4582     static assert(is(typeof(h3) == shared(const(Baz))*));
4583     static assert(is(typeof(h4) == const(Baz)));
4584     static assert(is(typeof(h5) == immutable(Baz)));
4585     static assert(is(typeof(h6) == shared(const(Baz))));
4586 }
4587 
4588 /***************************************************/
4589 // https://issues.dlang.org/show_bug.cgi?id=6630
4590 
4591 void test6630()
4592 {
4593     static class B {}
4594 
4595     static class A
4596     {
4597         this() { b = new B(); }
4598         B b;
4599         alias b this;
4600     }
4601 
4602     void fun(A a)
4603     {
4604         a = null;
4605         assert(a is null);
4606     }
4607 
4608     auto a = new A;
4609     assert(a.b !is null);
4610     fun(a);
4611     assert(a !is null);
4612     assert(a.b !is null);
4613 }
4614 
4615 /***************************************************/
4616 
4617 int i199 = 1;
4618 
4619 void test199()
4620 {
4621     label:
4622     {
4623         int i199 = 2;
4624     }
4625     assert(i199 == 1);
4626 }
4627 
4628 /***************************************************/
4629 // https://issues.dlang.org/show_bug.cgi?id=6690
4630 
4631 T useLazy6690(T)(lazy T val)
4632 {
4633     return val;
4634     // val is converted to delegate call, but it is typed as int delegate() - not @safe!
4635 }
4636 void test6690() @safe
4637 {
4638     useLazy6690(0);
4639     // Error: safe function 'test6690' cannot call system function 'useLazy6690'
4640 }
4641 
4642 /***************************************************/
4643 
4644 template Hoge6691()
4645 {
4646     immutable static int[int] dict;
4647     immutable static int value;
4648 
4649     shared static this()
4650     {
4651         dict = [1:1, 2:2];
4652         value = 10;
4653     }
4654 }
4655 alias Hoge6691!() H6691;
4656 
4657 /***************************************************/
4658 
4659 void test10626()
4660 {
4661     double[2] v, x;
4662     struct Y { double u; }
4663     double z;
4664     Y y;
4665     double[2] r = v[] * x[0];
4666     //double[2] s = v[] * z++;
4667     //double[2] t = v[] * z--;
4668     double[2] a = v[] * ++z;
4669     double[2] b = v[] * --z;
4670     double[2] c = v[] * y.u;
4671     x[] = 3;
4672     double[2] d = v[] * x[0];
4673     double[2] e = v[] * (v[] ~ z)[0];
4674 }
4675 
4676 
4677 /***************************************************/
4678 // https://issues.dlang.org/show_bug.cgi?id=2953
4679 
4680 template Tuple2953(T...)
4681 {
4682     alias T Tuple2953;
4683 }
4684 template Range2953(int b)
4685 {
4686     alias Tuple2953!(1) Range2953;
4687 }
4688 void foo2953()()
4689 {
4690     Tuple2953!(int, int) args;
4691     foreach( x ; Range2953!(args.length) ){ }
4692 }
4693 void test2953()
4694 {
4695     foo2953!()();
4696 }
4697 
4698 /***************************************************/
4699 // https://issues.dlang.org/show_bug.cgi?id=2997
4700 
4701 abstract class B2997 { void foo(); }
4702 interface I2997 { void bar(); }
4703 abstract class C2997 : B2997, I2997 {}
4704 //pragma(msg, __traits(allMembers, C).stringof);
4705 
4706 void test2997()
4707 {
4708     enum ObjectMembers = ["toString","toHash","opCmp","opEquals","Monitor","factory"];
4709 
4710     static assert([__traits(allMembers, C2997)] == ["foo"] ~ ObjectMembers ~ ["bar"]);
4711 }
4712 
4713 /***************************************************/
4714 // https://issues.dlang.org/show_bug.cgi?id=6596
4715 
4716 extern (C) int function() pfunc6596;
4717 extern (C) int cfunc6596(){ return 0; }
4718 static assert(typeof(pfunc6596).stringof == "extern (C) int function()");
4719 static assert(typeof(cfunc6596).stringof == "extern (C) int()");
4720 
4721 
4722 /***************************************************/
4723 // https://issues.dlang.org/show_bug.cgi?id=4423
4724 
4725 struct S4423
4726 {
4727     this(string phrase, int num)
4728     {
4729         this.phrase = phrase;
4730         this.num = num;
4731     }
4732 
4733     int opCmp(const ref S4423 rhs)
4734     {
4735         if (phrase < rhs.phrase)
4736             return -1;
4737         else if (phrase > rhs.phrase)
4738             return 1;
4739 
4740         if (num < rhs.num)
4741             return -1;
4742         else if (num > rhs.num)
4743             return 1;
4744 
4745         return 0;
4746     }
4747 
4748     string phrase;
4749     int    num;
4750 }
4751 
4752 enum E4423 : S4423
4753 {
4754     a = S4423("hello", 1),
4755     b = S4423("goodbye", 45),
4756     c = S4423("world", 22),
4757 };
4758 
4759 void test4423()
4760 {
4761     E4423 e;
4762     assert(e.phrase == "hello");
4763 
4764     e = E4423.b;
4765     assert(e.phrase == "goodbye");
4766 }
4767 
4768 /***************************************************/
4769 // https://issues.dlang.org/show_bug.cgi?id=4647
4770 
4771 interface Timer
4772 {
4773     final int run() { printf("Timer.run()\n"); fun(); return 1; };
4774     int fun();
4775 }
4776 
4777 interface Application
4778 {
4779     final int run() { printf("Application.run()\n"); fun(); return 2; };
4780     int fun();
4781 }
4782 
4783 class TimedApp : Timer, Application
4784 {
4785     int funCalls;
4786     override int fun()
4787     {
4788         printf("TimedApp.fun()\n");
4789         funCalls++;
4790         return 2;
4791     }
4792 }
4793 
4794 class SubTimedApp : TimedApp
4795 {
4796     int subFunCalls;
4797 
4798     override int fun()
4799     {
4800         printf("SubTimedApp.fun()\n");
4801         subFunCalls++;
4802         return 1;
4803     }
4804 }
4805 
4806 void test4647()
4807 {
4808     //Test access to TimedApps base interfaces
4809     auto app = new TimedApp();
4810     assert((cast(Application)app).run() == 2);
4811     assert((cast(Timer)app).run() == 1);
4812     assert(app.Timer.run() == 1); // error, no Timer property
4813     assert(app.Application.run() == 2); // error, no Application property
4814     assert(app.run() == 1);             // This would call Timer.run() if the two calls
4815                                         // above were commented out
4816     assert(app.funCalls == 5);
4817 
4818     assert(app.TimedApp.fun() == 2);
4819     assert(app.funCalls == 6);
4820 
4821     //Test direct access to SubTimedApp interfaces
4822     auto app2 = new SubTimedApp();
4823     assert((cast(Application)app2).run() == 2);
4824     assert((cast(Timer)app2).run() == 1);
4825     assert(app2.Application.run() == 2);
4826     assert(app2.Timer.run() == 1);
4827     assert(app2.funCalls == 0);
4828     assert(app2.subFunCalls == 4);
4829 
4830     assert(app2.fun() == 1);
4831     assert(app2.SubTimedApp.fun() == 1);
4832     assert(app2.funCalls == 0);
4833     assert(app2.subFunCalls == 6);
4834 
4835     //Test access to SubTimedApp interfaces via TimedApp
4836     auto app3 = new SubTimedApp();
4837     (cast(Timer)cast(TimedApp)app3).run();
4838     app3.TimedApp.Timer.run();
4839     assert((cast(Application)cast(TimedApp)app3).run() == 2);
4840     assert((cast(Timer)cast(TimedApp)app3).run() == 1);
4841     assert(app3.TimedApp.Application.run() == 2);
4842     assert(app3.TimedApp.Timer.run() == 1);
4843     assert(app3.funCalls == 0);
4844     assert(app3.subFunCalls == 6);
4845 }
4846 
4847 /***************************************************/
4848 
4849 template T1064(E...) { alias E T1064; }
4850 
4851 int[] var1064 = [ T1064!(T1064!(T1064!(1, 2), T1064!(), T1064!(3)), T1064!(4, T1064!(T1064!(T1064!(T1064!(5)))), T1064!(T1064!(T1064!(T1064!())))),6) ];
4852 
4853 void test1064()
4854 {
4855     assert(var1064 == [1,2,3,4,5,6]);
4856 }
4857 
4858 /***************************************************/
4859 // https://issues.dlang.org/show_bug.cgi?id=5696
4860 
4861 template Seq5696(T...){ alias T Seq5696; }
4862 template Pred5696(T) { alias T Pred5696; }  // TOKtemplate
4863 template Scope5696(int n){ template X(T) { alias T X; } }   // TOKimport
4864 T foo5696(T)(T x) { return x; }
4865 void test5696()
4866 {
4867     foreach (pred; Seq5696!(Pred5696, Pred5696))
4868     {
4869         static assert(is(pred!int == int));
4870     }
4871 
4872     foreach (scop; Seq5696!(Scope5696!0, Scope5696!1))
4873     {
4874         static assert(is(scop.X!int == int));
4875     }
4876 
4877     alias Seq5696!(foo5696, foo5696) funcs;
4878     assert(funcs[0](0) == 0);
4879     assert(funcs[1](1) == 1);
4880     foreach (i, fn; funcs)
4881     {
4882         assert(fn(i) == i);
4883     }
4884 }
4885 
4886 /***************************************************/
4887 // https://issues.dlang.org/show_bug.cgi?id=5933
4888 
4889 int dummyfunc5933();
4890 alias typeof(dummyfunc5933) FuncType5933;
4891 
4892 struct S5933a { auto x() { return 0; } }
4893 static assert(is(typeof(&S5933a.init.x) == int delegate() pure nothrow @nogc @safe));
4894 
4895 struct S5933b { auto x() { return 0; } }
4896 //static assert(is(typeof(S5933b.init.x) == FuncType5933));
4897 
4898 struct S5933c { auto x() { return 0; } }
4899 static assert(is(typeof(&S5933c.x) == int function()));
4900 
4901 struct S5933d { auto x() { return 0; } }
4902 static assert(is(typeof(S5933d.x) == FuncType5933));
4903 
4904 
4905 class C5933a { auto x() { return 0; } }
4906 static assert(is(typeof(&(new C5933b()).x) == int delegate()));
4907 
4908 class C5933b { auto x() { return 0; } }
4909 //static assert(is(typeof((new C5933b()).x) == FuncType5933));
4910 
4911 class C5933c { auto x() { return 0; } }
4912 static assert(is(typeof(&C5933c.x) == int function()));
4913 
4914 class C5933d { auto x() { return 0; } }
4915 static assert(is(typeof(C5933d.x) == FuncType5933));
4916 
4917 /***************************************************/
4918 // https://issues.dlang.org/show_bug.cgi?id=6084
4919 
4920 template TypeTuple6084(T...){ alias T TypeTuple6084; }
4921 void test6084()
4922 {
4923     int foo(int x)() { return x; }
4924     foreach(i; TypeTuple6084!(0))
4925         foo!(i);
4926 }
4927 
4928 /***************************************************/
4929 // https://issues.dlang.org/show_bug.cgi?id=6763
4930 
4931 template TypeTuple6763(TList...)
4932 {
4933     alias TList TypeTuple6763;
4934 }
4935 
4936 alias TypeTuple6763!(int) T6763;
4937 
4938 void f6763(      T6763) { } ///
4939 void c6763(const T6763) { } ///T now is (const int)
4940 void r6763(ref   T6763) { } ///T now is(ref const int)
4941 void i6763(in    T6763) { } ///Uncomment to get an Assertion failure in 'mtype.c'
4942 void o6763(out   T6763) { } ///ditto
4943 
4944 void test6763()
4945 {
4946     int n;
4947 
4948     f6763(0);   //With D2: Error: function main.f ((ref const const(int) _param_0)) is not callable using argument types (int)
4949     c6763(0);
4950     r6763(n);   static assert(__traits(compiles, r6763(0)));
4951     i6763(0);
4952     o6763(n);   static assert(!__traits(compiles, o6763(0)));
4953 
4954     // https://issues.dlang.org/show_bug.cgi?id=6755
4955     static assert(typeof(f6763).stringof == "void(int _param_0)");
4956     static assert(typeof(c6763).stringof == "void(const(int) _param_0)");
4957     static assert(typeof(r6763).stringof == "void(ref int _param_0)");
4958     static assert(typeof(i6763).stringof == "void(in int _param_0)");
4959     static assert(typeof(o6763).stringof == "void(out int _param_0)");
4960 }
4961 
4962 /***************************************************/
4963 // https://issues.dlang.org/show_bug.cgi?id=6695
4964 
4965 struct X6695
4966 {
4967     void mfunc()
4968     {
4969         static assert(is(typeof(this) == X6695));
4970     }
4971     void cfunc() const
4972     {
4973         static assert(is(typeof(this) == const(X6695)));
4974     }
4975     void ifunc() immutable
4976     {
4977         static assert(is(typeof(this) == immutable(X6695)));
4978     }
4979     void sfunc() shared
4980     {
4981         static assert(is(typeof(this) == shared(X6695)));
4982     }
4983     void scfunc() shared const
4984     {
4985         static assert(is(typeof(this) == shared(const(X6695))));
4986     }
4987     void wfunc() inout
4988     {
4989         static assert(is(typeof(this) == inout(X6695)));
4990     }
4991     void swfunc() shared inout
4992     {
4993         static assert(is(typeof(this) == shared(inout(X6695))));
4994     }
4995 
4996     static assert(is(typeof(this) == X6695));
4997 }
4998 
4999 /***************************************************/
5000 // https://issues.dlang.org/show_bug.cgi?id=6087
5001 
5002 template True6087(T)
5003 {
5004     immutable True6087 = true;
5005 }
5006 struct Foo6087
5007 {
5008     static assert( True6087!(typeof(this)) );
5009 }
5010 
5011 struct Bar6087
5012 {
5013     static assert( is(typeof(this) == Bar6087) );
5014 }
5015 
5016 /***************************************************/
5017 // https://issues.dlang.org/show_bug.cgi?id=6848
5018 
5019 class Foo6848 {}
5020 
5021 class Bar6848 : Foo6848
5022 {
5023     void func() immutable
5024     {
5025         static assert(is(typeof(this) == immutable(Bar6848)));  // immutable(Bar6848)
5026         auto t = this;
5027         static assert(is(typeof(t) == immutable(Bar6848)));     // immutable(Bar6848)
5028 
5029         static assert(is(typeof(super) == immutable(Foo6848))); // Foo6848 instead of immutable(Foo6848)
5030         auto s = super;
5031         static assert(is(typeof(s) == immutable(Foo6848)));     // Foo6848 instead of immutable(Foo6848)
5032     }
5033 }
5034 
5035 /***************************************************/
5036 
5037 version(none)
5038 {
5039     cent issue785;
5040     ucent issue785;
5041 }
5042 
5043 static assert(is(cent) && is(ucent) || !is(cent) && !is(ucent));
5044 static if (is(cent))
5045   static assert(__traits(compiles, { cent x; }));
5046 else
5047   static assert(!__traits(compiles, { cent x; }));
5048 
5049 /***************************************************/
5050 // https://issues.dlang.org/show_bug.cgi?id=6847
5051 
5052 template True6847(T)
5053 {
5054     immutable True6847 = true;
5055 }
5056 class Foo6847
5057 {}
5058 
5059 class Bar6847 : Foo6847
5060 {
5061     static assert( True6847!(typeof(super)) );
5062     static assert( is(typeof(super) == Foo6847) );
5063 }
5064 
5065 /***************************************************/
5066 // http://d.puremagic.com/issues/show_bug.cgi?id=6488
5067 
5068 struct TickDuration
5069 {
5070     template to(T) if (__traits(isIntegral,T))
5071     {
5072         const T to()
5073         {
5074             return 1;
5075         }
5076     }
5077 
5078     template to(T) if (__traits(isFloating,T))
5079     {
5080         const T to()
5081         {
5082             return 0;
5083         }
5084     }
5085 
5086     const long seconds()
5087     {
5088         return to!(long)();
5089     }
5090 
5091 }
5092 
5093 void test6488()
5094 {
5095     TickDuration d;
5096     d.seconds();
5097 }
5098 
5099 /***************************************************/
5100 // https://issues.dlang.org/show_bug.cgi?id=6565
5101 
5102 void foo6565(out int[2][2] m) {}
5103 
5104 void test6565()
5105 {
5106     int[2][2] mat = [[1, 2], [3, 4]];
5107     foo6565(mat);
5108     assert(mat == [[0, 0], [0, 0]]);
5109 }
5110 
5111 /***************************************************/
5112 // https://issues.dlang.org/show_bug.cgi?id=6836
5113 
5114 template map6836(fun...) if (fun.length >= 1)
5115 {
5116     auto map6836(Range)(Range r)
5117     {
5118     }
5119 }
5120 void test6836()
5121 {
5122     [1].map6836!"a"();
5123 }
5124 
5125 /***************************************************/
5126 
5127 string func12864() { return ['a', 'b', 'c']; }
5128 
5129 void test12864(string s)
5130 {
5131     switch (s)
5132     {
5133     case func12864():
5134         break;
5135 
5136     default:
5137         break;
5138     }
5139 }
5140 
5141 /***************************************************/
5142 
5143 void test5448()
5144 {
5145     int[int][] aaa = [[1: 2]];
5146     int[string][] a2 = [["cc":0], ["DD":10]];
5147 }
5148 
5149 /***************************************************/
5150 // https://issues.dlang.org/show_bug.cgi?id=6837
5151 
5152 struct Ref6837a(T)
5153 {
5154     T storage;
5155     alias storage this;
5156 }
5157 
5158 struct Ref6837b(T)
5159 {
5160     T storage;
5161     @property ref T get(){ return storage; }
5162     alias get this;
5163 }
5164 
5165 int front6837(int[] arr){ return arr[0]; }
5166 
5167 void popFront6837(ref int[] arr){ arr = arr[1..$]; }
5168 
5169 void test6837()
5170 {
5171     assert([1,2,3].front6837 == 1);
5172 
5173     auto r1 = Ref6837a!(int[])([1,2,3]);
5174     assert(r1.front6837() == 1);    // ng
5175     assert(r1.front6837 == 1);      // ok
5176     r1.popFront6837();              // ng
5177     r1.storage.popFront6837();      // ok
5178 
5179     auto r2 = Ref6837b!(int[])([1,2,3]);
5180     assert(r2.front6837() == 1);    // ng
5181     assert(r2.front6837 == 1);      // ok
5182     r2.popFront6837();              // ng
5183     r2.get.popFront6837();          // ng
5184     r2.get().popFront6837();        // ok
5185 }
5186 
5187 /***************************************************/
5188 // https://issues.dlang.org/show_bug.cgi?id=6927
5189 
5190 @property int[] foo6927()
5191 {
5192     return [1, 2];
5193 }
5194 int[] bar6927(int[] a)
5195 {
5196     return a;
5197 }
5198 void test6927()
5199 {
5200     bar6927(foo6927); // OK
5201     foo6927.bar6927(); // line 9, Error
5202 }
5203 
5204 /***************************************************/
5205 
5206 struct Foo6813(T)
5207 {
5208     Foo6813 Bar()
5209     {
5210         return Foo6813(_indices.abc());
5211     }
5212 
5213     T _indices;
5214 }
5215 
5216 struct SortedRange(alias pred)
5217 {
5218     SortedRange abc()
5219     {
5220         return SortedRange();
5221     }
5222 }
5223 
5224 void test6813() {
5225     auto ind = SortedRange!({ })();
5226     auto a = Foo6813!(typeof(ind))();
5227 }
5228 
5229 /***************************************************/
5230 
5231 struct Interval6753{ int a,b; }
5232 @safe struct S6753
5233 {
5234     int[] arr;
5235     @trusted @property auto byInterval() const
5236     {
5237         return cast(const(Interval6753)[])arr;
5238     }
5239 }
5240 
5241 /***************************************************/
5242 // https://issues.dlang.org/show_bug.cgi?id=6859
5243 
5244 class Parent6859
5245 {
5246 public:
5247     bool isHage() const @property;
5248 
5249 public:
5250     abstract void fuga()
5251     out
5252     {
5253         assert(isHage);
5254     }
5255     do { }
5256 }
5257 
5258 class Child6859 : Parent6859
5259 {
5260     override bool isHage() const @property
5261     {
5262         return true;
5263     }
5264     override void fuga()
5265     {
5266         //nop
5267     }
5268 }
5269 
5270 void test6859()
5271 {
5272     auto t = new Child6859;
5273     t.fuga();
5274     printf("done.\n");
5275 }
5276 
5277 /***************************************************/
5278 // https://issues.dlang.org/show_bug.cgi?id=6910
5279 
5280 template Test6910(alias i, B)
5281 {
5282     void fn()
5283     {
5284         foreach(t; B.Types)
5285         {
5286             switch(i)
5287             {
5288                 case 0://IndexOf!(t, B.Types):
5289                 {
5290                     pragma(msg, __traits(allMembers, t));
5291                     pragma(msg, __traits(hasMember, t, "m"));
5292                     static assert(__traits(hasMember, t, "m")); // test
5293                     break;
5294                 }
5295                 default: {}
5296             }
5297         }
5298     }
5299 }
5300 void test6910()
5301 {
5302     static struct Bag(S...)
5303     {
5304         alias S Types;
5305     }
5306     static struct A
5307     {
5308         int m;
5309     }
5310 
5311     int i;
5312     alias Test6910!(i, Bag!(A)).fn func;
5313 }
5314 
5315 /***************************************************/
5316 
5317 void fun12503()
5318 {
5319     string b = "abc";
5320     try
5321     {
5322         try
5323         {
5324             b = null;
5325             return;
5326         }
5327         catch(Throwable)
5328         {
5329         }
5330     }
5331     finally
5332     {
5333         assert("abc" !is b);
5334     }
5335 }
5336 
5337 void test12503()
5338 {
5339     fun12503();
5340 }
5341 
5342 /***************************************************/
5343 // https://issues.dlang.org/show_bug.cgi?id=6902
5344 
5345 void test6902()
5346 {
5347     static assert(is(typeof({
5348         return int.init; // int, long, real, etc.
5349     })));
5350 
5351     int f() pure nothrow { assert(0); }
5352     alias int T() pure nothrow @safe @nogc;
5353     static if(is(typeof(&f) DT == delegate))
5354     {
5355         static assert(is(DT* == T*));  // ok
5356 
5357         // Error: static assert  (is(pure nothrow int() == pure nothrow int())) is false
5358         static assert(is(DT == T));
5359     }
5360 }
5361 
5362 /***************************************************/
5363 // https://issues.dlang.org/show_bug.cgi?id=6330
5364 
5365 struct S6330
5366 {
5367     void opAssign(S6330 s) @disable
5368     {
5369         assert(0);  // This fails.
5370     }
5371 }
5372 
5373 void test6330()
5374 {
5375     S6330 s;
5376     S6330 s2;
5377     static assert(!is(typeof({ s2 = s; })));
5378 }
5379 
5380 /***************************************************/
5381 
5382 struct S8269
5383 {
5384     bool dtor = false;
5385     ~this()
5386     {
5387         dtor = true;
5388     }
5389 }
5390 
5391 void test8269()
5392 {
5393     with(S8269())
5394     {
5395         assert(!dtor);
5396     }
5397 }
5398 
5399 /***************************************************/
5400 // https://issues.dlang.org/show_bug.cgi?id=5311
5401 
5402 class C5311
5403 {
5404     private static int globalData;
5405 
5406     void breaksPure() pure const
5407     {
5408         static assert(!__traits(compiles, { globalData++; }));      // SHOULD BE ERROR
5409         static assert(!__traits(compiles, { C5311.globalData++; }));// SHOULD BE ERROR
5410         static assert(!__traits(compiles, { this.globalData++; })); // SHOULD BE ERROR
5411 
5412         static assert(!__traits(compiles, { int a = this.globalData; }));
5413     }
5414 }
5415 static void breaksPure5311a(C5311 x) pure
5416 {
5417     static assert(!__traits(compiles, { x.globalData++; }));        // SHOULD BE ERROR
5418 
5419     static assert(!__traits(compiles, { int a = x.globalData; }));
5420 }
5421 
5422 struct S5311
5423 {
5424     private static int globalData;
5425 
5426     void breaksPure() pure const
5427     {
5428         static assert(!__traits(compiles, { globalData++; }));      // SHOULD BE ERROR
5429         static assert(!__traits(compiles, { S5311.globalData++; }));// SHOULD BE ERROR
5430         static assert(!__traits(compiles, { this.globalData++; })); // SHOULD BE ERROR
5431 
5432         static assert(!__traits(compiles, { int a = this.globalData; }));
5433     }
5434 }
5435 static void breaksPure5311b(S5311 x) pure
5436 {
5437     static assert(!__traits(compiles, { x.globalData++; }));        // SHOULD BE ERROR
5438 
5439     static assert(!__traits(compiles, { int a = x.globalData; }));
5440 }
5441 
5442 /***************************************************/
5443 // https://issues.dlang.org/show_bug.cgi?id=6868
5444 
5445 @property bool empty6868(T)(in T[] a) @safe pure nothrow
5446 {
5447     return !a.length;
5448 }
5449 
5450 void test6868()
5451 {
5452     alias int[] Range;
5453     static if (is(char[1 + Range.empty6868]))  // Line 9
5454         enum bool isInfinite = true;
5455 
5456     char[0] s;  // need
5457 }
5458 
5459 /***************************************************/
5460 // https://issues.dlang.org/show_bug.cgi?id=2856
5461 
5462 struct foo2856    { static void opIndex(int i) { printf("foo\n"); } }
5463 struct bar2856(T) { static void opIndex(int i) { printf("bar\n"); } }
5464 
5465 void test2856()
5466 {
5467     foo2856[1];
5468     bar2856!(float)[1];     // Error (# = __LINE__)
5469     alias bar2856!(float) B;
5470     B[1];                   // Okay
5471 }
5472 
5473 /***************************************************/
5474 
5475 void test13947()
5476 {
5477     struct S {}
5478     static assert(S.sizeof == 1);
5479 
5480     S a;
5481     S b;
5482     *cast(ubyte*)&a = 1;
5483     *cast(ubyte*)&b = 2;
5484     assert(a == b);
5485     assert(a is b);
5486     assert(!(a != b));
5487     assert(!(a !is b));
5488     static assert(S() == S());
5489     static assert(S() is S());
5490     static assert(!(S() != S()));
5491     static assert(!(S() !is S()));
5492 }
5493 
5494 /***************************************************/
5495 // https://issues.dlang.org/show_bug.cgi?id=3091
5496 
5497 void test3091(inout int = 0)
5498 {
5499     struct Foo {}
5500 
5501     auto  pm = new Foo;                 static assert(is( typeof( pm) ==              Foo  * ));
5502     auto  pc = new const Foo;           static assert(is( typeof( pc) ==        const(Foo) * ));
5503     auto  pw = new inout Foo;           static assert(is( typeof( pw) ==        inout(Foo) * ));
5504     auto psm = new shared Foo;          static assert(is( typeof(psm) ==       shared(Foo) * ));
5505     auto psc = new shared const Foo;    static assert(is( typeof(psc) == shared(const(Foo))* ));
5506     auto psw = new shared inout Foo;    static assert(is( typeof(psw) == shared(inout(Foo))* ));
5507     auto  pi = new immutable Foo;       static assert(is( typeof( pi) ==    immutable(Foo) * ));
5508 
5509     auto  m = Foo();                    static assert(is( typeof( m) ==              Foo   ));
5510     auto  c = const Foo();              static assert(is( typeof( c) ==        const(Foo)  ));
5511     auto  w = inout Foo();              static assert(is( typeof( w) ==        inout(Foo)  ));
5512     auto sm = shared Foo();             static assert(is( typeof(sm) ==       shared(Foo)  ));
5513     auto sc = shared const Foo();       static assert(is( typeof(sc) == shared(const(Foo)) ));
5514     auto sw = shared inout Foo();       static assert(is( typeof(sw) == shared(inout(Foo)) ));
5515     auto  i = immutable Foo();          static assert(is( typeof( i) ==    immutable(Foo)  ));
5516 }
5517 
5518 /***************************************************/
5519 // https://issues.dlang.org/show_bug.cgi?id=6837
5520 
5521 template Id6837(T)
5522 {
5523     alias T Id6837;
5524 }
5525 static assert(is(Id6837!(shared const int) == shared const int));
5526 static assert(is(Id6837!(shared inout int) == shared inout int));
5527 
5528 /***************************************************/
5529 // https://issues.dlang.org/show_bug.cgi?id=6056 fixup
5530 
5531 template ParameterTypeTuple6056(func)
5532 {
5533     static if (is(func Fptr : Fptr*) && is(Fptr P == function))
5534         alias P ParameterTypeTuple6056;
5535     else
5536         static assert(0, "argument has no parameters");
5537 }
5538 
5539 extern(C) alias void function() fpw_t;
5540 
5541 alias void function(fpw_t fp) cb_t;
5542 
5543 void bar6056(ParameterTypeTuple6056!(cb_t) args) {
5544       pragma (msg, "TFunction1: " ~ typeof(args[0]).stringof);
5545 }
5546 
5547 extern(C) void foo6056() { }
5548 
5549 void test6056()
5550 {
5551     bar6056(&foo6056);
5552 }
5553 
5554 /***************************************************/
5555 // https://issues.dlang.org/show_bug.cgi?id=6356
5556 
5557 int f6356()(int a)
5558 {
5559     return a*a;
5560 }
5561 
5562 alias f6356!() g6356;     // comment this out to eliminate the errors
5563 
5564 pure nothrow @safe int i6356()
5565 {
5566     return f6356(1);
5567 }
5568 
5569 void test6356()
5570 {
5571     assert(i6356() == 1);
5572 }
5573 
5574 /***************************************************/
5575 // https://issues.dlang.org/show_bug.cgi?id=7108
5576 
5577 static assert(!__traits(hasMember, int, "x"));
5578 static assert( __traits(hasMember, int, "init"));
5579 
5580 /***************************************************/
5581 // https://issues.dlang.org/show_bug.cgi?id=7073
5582 
5583 void test7073()
5584 {
5585     string f(int[] arr...)
5586     {
5587         return "";
5588     }
5589 }
5590 
5591 /***************************************************/
5592 // https://issues.dlang.org/show_bug.cgi?id=7104
5593 
5594 void test7104()
5595 {
5596     typeof(new class {}) c;
5597     c = new typeof(c);
5598 }
5599 
5600 /***************************************************/
5601 // https://issues.dlang.org/show_bug.cgi?id=7150
5602 
5603 struct A7150
5604 {
5605     static int cnt;
5606 
5607     this(T)(T thing, int i)
5608     {
5609         this(thing, i > 0); // Error: constructor call must be in a constructor
5610         ++cnt;
5611     }
5612     this(T)(T thing, bool b)
5613     {
5614         ++cnt;
5615     }
5616 }
5617 
5618 void test7150()
5619 {
5620     auto a = A7150(5, 5); // Error: template instance constructtest.A.__ctor!(int) error instantiating
5621     assert(A7150.cnt == 2);
5622 }
5623 
5624 /***************************************************/
5625 // https://issues.dlang.org/show_bug.cgi?id=7159
5626 
5627 alias void delegate()  Void7159;
5628 
5629 class HomeController7159 {
5630     Void7159 foo() {
5631         return cast(Void7159)&HomeController7159.displayDefault;
5632     }
5633     auto displayDefault() {
5634         return 1;
5635     }
5636 }
5637 
5638 /***************************************************/
5639 // https://issues.dlang.org/show_bug.cgi?id=7160
5640 
5641 class HomeController {
5642     static if (false) {
5643         mixin(q{ int a; });
5644     }
5645     void foo() {
5646         foreach (m; __traits(derivedMembers, HomeController)) {
5647         }
5648     }
5649 }
5650 
5651 void test7160()
5652 {}
5653 
5654 /***************************************************/
5655 // https://issues.dlang.org/show_bug.cgi?id=7168
5656 
5657 void test7168()
5658 {
5659     static class X
5660     {
5661         void foo(){}
5662     }
5663     static class Y : X
5664     {
5665         void bar(){}
5666     }
5667 
5668     enum ObjectMembers = ["toString","toHash","opCmp","opEquals","Monitor","factory"];
5669 
5670     static assert([__traits(allMembers, X)] == ["foo"]~ObjectMembers);          // pass
5671     static assert([__traits(allMembers, Y)] == ["bar", "foo"]~ObjectMembers);   // fail
5672     static assert([__traits(allMembers, Y)] != ["bar", "foo"]);                 // fail
5673 }
5674 
5675 /***************************************************/
5676 // https://issues.dlang.org/show_bug.cgi?id=7170
5677 
5678 T to7170(T)(string x) { return 1; }
5679 void test7170()
5680 {
5681 //  auto i = to7170!int("1");   // OK
5682     auto j = "1".to7170!int();  // NG, Internal error: e2ir.c 683
5683 }
5684 
5685 /***************************************************/
5686 // https://issues.dlang.org/show_bug.cgi?id=7196
5687 
5688 auto foo7196(int x){return x;}
5689 auto foo7196(double x){return x;}
5690 
5691 void test7196()
5692 {
5693     auto x = (&foo7196)(1);   // ok
5694     auto y = (&foo7196)(1.0); // fail
5695 }
5696 
5697 /***************************************************/
5698 // https://issues.dlang.org/show_bug.cgi?id=7285
5699 
5700 int[2] spam7285()
5701 {
5702     int[2] ab;
5703     if (true)
5704         return (true) ? ab : [0, 0]; // Error
5705     else
5706         return (true) ? [0, 0] : ab; // OK
5707 }
5708 
5709 void test7285()
5710 {
5711     auto sa = spam7285();
5712 }
5713 
5714 /***************************************************/
5715 // https://issues.dlang.org/show_bug.cgi?id=14737
5716 
5717 void test14737()
5718 {
5719     // compile-time
5720     enum string[2] a1 = ["d", "e"];
5721     enum b1x = ["a", "b", "c"] ~ a1;        // Tarray vs Tsarray
5722     enum b1y = a1 ~ ["a", "b", "c"];        // Tsarray vs Tarray
5723     static assert(is(typeof(b1x) == string[]));
5724     static assert(is(typeof(b1y) == string[]));
5725     static assert(b1x == ["a", "b", "c", "d", "e"]);
5726     static assert(b1y == ["d", "e", "a", "b", "c"]);
5727 
5728     // runtime
5729     string[2] a2 = ["d", "e"];
5730     auto b2x = ["a", "b", "c"] ~ a2;        // Tarray vs Tsarray
5731     auto b2y = a2 ~ ["a", "b", "c"];        // Tsarray vs Tarray
5732     static assert(is(typeof(b2x) == string[]));
5733     static assert(is(typeof(b2y) == string[]));
5734     assert(b2x == ["a", "b", "c", "d", "e"]);
5735     assert(b2y == ["d", "e", "a", "b", "c"]);
5736 }
5737 
5738 /***************************************************/
5739 // https://issues.dlang.org/show_bug.cgi?id=7321
5740 
5741 void test7321()
5742 {
5743     static assert(is(typeof((){})==void function()pure nothrow @nogc @safe));         // ok
5744     static assert(is(typeof((){return;})==void function()pure nothrow @nogc @safe));  // fail
5745 }
5746 
5747 /***************************************************/
5748 
5749 class A158
5750 {
5751     pure void foo1() { }
5752     const void foo2() { }
5753     nothrow void foo3() { }
5754     @safe void foo4() { }
5755 }
5756 
5757 class B158 : A158
5758 {
5759     override void foo1() { }
5760     override void foo2() const { }
5761     override void foo3() { }
5762     override void foo4() { }
5763 }
5764 
5765 /***************************************************/
5766 // https://issues.dlang.org/show_bug.cgi?id=9231
5767 
5768 class B9231 { void foo() inout pure {} }
5769 class D9231 : B9231 { override void foo() inout {} }
5770 
5771 /***************************************************/
5772 // https://issues.dlang.org/show_bug.cgi?id=3282
5773 
5774 class Base3282
5775 {
5776     string f()
5777     {
5778         return "Base.f()";
5779     }
5780 }
5781 class Derived3282 : Base3282
5782 {
5783     override string f()
5784     {
5785         return "Derived.f()";
5786     }
5787   /*override*/ string f() const
5788     {
5789         return "Derived.f() const";
5790     }
5791 }
5792 
5793 void test3282()
5794 {
5795     auto x = new Base3282;
5796     assert(x.f() == "Base.f()");
5797     auto y = new Derived3282;
5798     assert(y.f() == "Derived.f()");// calls "Derived.f() const", but it is expected that be called non-const.
5799     auto z = new const(Derived3282);
5800     assert(z.f() == "Derived.f() const");
5801 }
5802 
5803 /***************************************************/
5804 // https://issues.dlang.org/show_bug.cgi?id=7534
5805 
5806 class C7534
5807 {
5808     int foo(){ return 1; }
5809 }
5810 class D7534 : C7534
5811 {
5812     override int foo(){ return 2; }
5813   /*override*/ int foo() const { return 3; }
5814     // Error: D.foo multiple overrides of same function
5815 }
5816 void test7534()
5817 {
5818     C7534 mc = new C7534();
5819     assert(mc.foo() == 1);
5820 
5821     D7534 md = new D7534();
5822     assert(md.foo() == 2);
5823     mc = md;
5824     assert(mc.foo() == 2);
5825 
5826     const(D7534) cd = new const(D7534)();
5827     assert(cd.foo() == 3);
5828     md = cast()cd;
5829     assert(md.foo() == 2);
5830 }
5831 
5832 /***************************************************/
5833 // https://issues.dlang.org/show_bug.cgi?id=7534
5834 // return type covariance
5835 
5836 class X7534 {}
5837 class Y7534 : X7534
5838 {
5839     int value; this(int n){ value = n; }
5840 }
5841 
5842 class V7534
5843 {
5844     X7534 foo(){ return new X7534(); }
5845 }
5846 class W7534 : V7534
5847 {
5848     override Y7534 foo(){ return new Y7534(1); }
5849   /*override*/ Y7534 foo() const { return new Y7534(2); }
5850 }
5851 
5852 void test7534cov()
5853 {
5854     auto mv = new V7534();
5855     assert(typeid(mv.foo()) == typeid(X7534));
5856 
5857     auto mw = new W7534();
5858     assert(typeid(mw.foo()) == typeid(Y7534));
5859     assert(mw.foo().value == 1);
5860     mv = mw;
5861     assert(typeid(mv.foo()) == typeid(Y7534));
5862     assert((cast(Y7534)mv.foo()).value == 1);
5863 
5864     auto cw = new const(W7534)();
5865     assert(typeid(cw.foo()) == typeid(Y7534));
5866     assert(cw.foo().value == 2);
5867 }
5868 
5869 /***************************************************/
5870 // https://issues.dlang.org/show_bug.cgi?id=7562
5871 
5872 static struct MyInt
5873 {
5874     private int value;
5875     mixin ProxyOf!value;
5876 }
5877 mixin template ProxyOf(alias a)
5878 {
5879     template X1(){}
5880     template X2(){}
5881     template X3(){}
5882     template X4(){}
5883     template X5(){}
5884     template X6(){}
5885     template X7(){}
5886     template X8(){}
5887     template X9(){}
5888     template X10(){}
5889 
5890     void test1(this X)(){}
5891     void test2(this Y)(){}
5892 }
5893 
5894 /***************************************************/
5895 
5896 import core.stdc.stdlib;
5897 
5898 void test13427(void* buffer = alloca(100))
5899 {
5900 }
5901 
5902 /***************************************************/
5903 // https://issues.dlang.org/show_bug.cgi?id=7583
5904 
5905 template Tup7583(E...) { alias E Tup7583; }
5906 
5907 struct S7583
5908 {
5909     Tup7583!(float, char) field;
5910     alias field this;
5911     this(int x) {    }
5912 }
5913 
5914 int bug7583() {
5915     S7583[] arr;
5916     arr ~= S7583(0);
5917     return 1;
5918 }
5919 
5920 static assert (bug7583());
5921 
5922 /***************************************************/
5923 // https://issues.dlang.org/show_bug.cgi?id=7618
5924 
5925 void test7618(const int x = 1)
5926 {
5927     int func(ref int x) { return 1; }
5928     static assert(!__traits(compiles, func(x)));
5929     // Error: function test.foo.func (ref int _param_0) is not callable using argument types (const(int))
5930 
5931     int delegate(ref int) dg = (ref int x) => 1;
5932     static assert(!__traits(compiles, dg(x)));
5933     // --> no error, bad!
5934 
5935     int function(ref int) fp = (ref int x) => 1;
5936     static assert(!__traits(compiles, fp(x)));
5937     // --> no error, bad!
5938 }
5939 
5940 /***************************************************/
5941 // https://issues.dlang.org/show_bug.cgi?id=7621
5942 
5943 void test7621()
5944 {
5945     enum uint N = 4u;
5946     char[] A = "hello".dup;
5947     uint[immutable char[4u]] dict;
5948     dict[*cast(immutable char[4]*)(A[0 .. N].ptr)] = 0; // OK
5949     dict[*cast(immutable char[N]*)(A[0 .. N].ptr)] = 0; // line 6, error
5950 }
5951 
5952 /***************************************************/
5953 // https://issues.dlang.org/show_bug.cgi?id=7682
5954 
5955 template ConstOf7682(T)
5956 {
5957     alias const(T) ConstOf7682;
5958 }
5959 bool pointsTo7682(S)(ref const S source) @trusted pure nothrow
5960 {
5961     return true;
5962 }
5963 void test7682()
5964 {
5965     shared(ConstOf7682!(int[])) x;  // line A
5966 
5967     struct S3 { int[10] a; }
5968     shared(S3) sh3;
5969     shared(int[]) sh3sub = sh3.a[];
5970     assert(pointsTo7682(sh3sub));   // line B
5971 }
5972 
5973 /***************************************************/
5974 // https://issues.dlang.org/show_bug.cgi?id=7735
5975 
5976 void a7735(void[][] data...)
5977 {
5978     //writeln(data);
5979     assert(data.length == 1);
5980     b7735(data);
5981 }
5982 
5983 void b7735(void[][] data...)
5984 {
5985     //writeln(data);
5986     assert(data.length == 1);
5987     c7735(data);
5988 }
5989 
5990 void c7735(void[][] data...)
5991 {
5992     //writeln(data);
5993     assert(data.length == 1);
5994 }
5995 
5996 void test7735()
5997 {
5998     a7735([]);
5999     a7735([]);
6000 }
6001 
6002 /***************************************************/
6003 
6004 struct A7823 {
6005     long a;
6006     enum A7823 b = {0};
6007 }
6008 
6009 void test7823(A7823 a = A7823.b) { }
6010 
6011 /***************************************************/
6012 // https://issues.dlang.org/show_bug.cgi?id=7871
6013 
6014 struct Tuple7871
6015 {
6016     string field;
6017     alias field this;
6018 }
6019 
6020 //auto findSplitBefore(R1)(R1 haystack)
6021 auto findSplitBefore7871(string haystack)
6022 {
6023     return Tuple7871(haystack);
6024 }
6025 
6026 void test7871()
6027 {
6028     string line = `<bookmark href="https://stuff">`;
6029     auto a = findSplitBefore7871(line[0 .. $])[0];
6030 }
6031 
6032 /***************************************************/
6033 // https://issues.dlang.org/show_bug.cgi?id=7906
6034 
6035 void test7906()
6036 {
6037     static assert(!__traits(compiles, { enum s = [string.min]; }));
6038 }
6039 
6040 /***************************************************/
6041 // https://issues.dlang.org/show_bug.cgi?id=7907
6042 
6043 template Id7907(E)
6044 {
6045     alias E Id7907;
6046 }
6047 template Id7907(alias E)
6048 {
6049     alias E Id7907;
6050 }
6051 
6052 void test7907()
6053 {
6054     static assert(!__traits(compiles, { alias Id7907!([string.min]) X; }));
6055 }
6056 
6057 /***************************************************/
6058 // https://issues.dlang.org/show_bug.cgi?id=1175
6059 
6060 class A1175
6061 {
6062     class I1 { }
6063 }
6064 
6065 class B1175 : A1175
6066 {
6067     class I2 : I1 { }
6068 
6069     I1 getI() { return new I2; }
6070 }
6071 
6072 /***************************************************/
6073 // https://issues.dlang.org/show_bug.cgi?id=8004
6074 
6075 void test8004()
6076 {
6077     auto n = (int n = 10){ return n; }();
6078     assert(n == 10);
6079 }
6080 
6081 /***************************************************/
6082 // https://issues.dlang.org/show_bug.cgi?id=8064
6083 
6084 void test8064()
6085 {
6086     uint[5] arry;
6087     ref uint acc(size_t i) {
6088         return arry[i];
6089     }
6090     auto arryacc = &acc;
6091     arryacc(3) = 5; // same error
6092 }
6093 
6094 /***************************************************/
6095 // https://issues.dlang.org/show_bug.cgi?id=8220
6096 
6097 void foo8220(int){}
6098 static assert(!__traits(compiles, foo8220(typeof(0)))); // fail
6099 
6100 /***************************************************/
6101 
6102 void func8105(in ref int x) { }
6103 
6104 void test8105()
6105 {
6106 }
6107 
6108 /***************************************************/
6109 
6110 template ParameterTypeTuple159(alias foo)
6111 {
6112     static if (is(typeof(foo) P == __parameters))
6113         alias P ParameterTypeTuple159;
6114     else
6115         static assert(0, "argument has no parameters");
6116 }
6117 
6118 int func159(int i, long j = 7) { return 3; }
6119 
6120 alias ParameterTypeTuple159!func159 PT;
6121 
6122 int bar159(PT) { return 4; }
6123 
6124 pragma(msg, typeof(bar159));
6125 pragma(msg, PT[1]);
6126 
6127 PT[1] boo159(PT[1..2] a) { return a[0]; }
6128 
6129 void test159()
6130 {
6131     assert(bar159(1) == 4);
6132     assert(boo159() == 7);
6133 }
6134 
6135 /***************************************************/
6136 // https://issues.dlang.org/show_bug.cgi?id=8283
6137 
6138 struct Foo8283 {
6139     this(long) { }
6140 }
6141 
6142 struct FooContainer {
6143     Foo8283 value;
6144 }
6145 
6146 auto get8283() {
6147     union Buf { FooContainer result; }
6148     Buf buf = {};
6149     return buf.result;
6150 }
6151 
6152 void test8283() {
6153     auto a = get8283();
6154 }
6155 
6156 
6157 /***************************************************/
6158 // https://issues.dlang.org/show_bug.cgi?id=8395
6159 
6160 struct S8395
6161 {
6162     int v;
6163     this(T : long)(T x) { v = x * 2; }
6164 }
6165 void test8395()
6166 {
6167     S8395 ms = 6;
6168     assert(ms.v == 12);
6169     const S8395 cs = 7;
6170     assert(cs.v == 14);
6171 }
6172 
6173 /***************************************************/
6174 // https://issues.dlang.org/show_bug.cgi?id=5749
6175 
6176 void test5749()
6177 {
6178     static struct A
6179     {
6180         A foo(int x, int i)
6181         {
6182             //printf("this = %p, %d: i=%d\n", &this, x, i);
6183             assert(i == x);
6184             return this;
6185         }
6186         A bar(int x, ref int i)
6187         {
6188             //printf("this = %p, %d: i=%d\n", &this, x, i);
6189             assert(i == x);
6190             return this;
6191         }
6192     }
6193 
6194     static     int inc1(ref int i) { return ++i; }
6195     static ref int inc2(ref int i) { return ++i; }
6196 
6197     int i;
6198     A a;
6199     //printf("&a = %p\n", &a);
6200 
6201     i = 0;  a.foo(1, ++i).foo(2, ++i);          // OK <-- 2 1
6202     i = 0;  a.bar(1, ++i).bar(2, ++i);          // OK <-- 2 2
6203     i = 0;  a.foo(1, inc1(i)).foo(2, inc1(i));  // OK <-- 2 1
6204     i = 0;  a.bar(1, inc2(i)).bar(2, inc2(i));  // OK <-- 2 2
6205     //printf("\n");
6206 
6207     A getVal() { static A a; return a; }
6208     i = 0;  getVal().foo(1, ++i).foo(2, ++i);           // OK <-- 2 1
6209     i = 0;  getVal().bar(1, ++i).bar(2, ++i);           // OK <-- 2 2
6210     i = 0;  getVal().foo(1, inc1(i)).foo(2, inc1(i));   // OK <-- 2 1
6211     i = 0;  getVal().bar(1, inc2(i)).bar(2, inc2(i));   // OK <-- 2 2
6212     //printf("\n");
6213 
6214     ref A getRef() { static A a; return a; }
6215     i = 0;  getRef().foo(1, ++i).foo(2, ++i);           // OK <-- 2 1
6216     i = 0;  getRef().bar(1, ++i).bar(2, ++i);           // OK <-- 2 2
6217     i = 0;  getRef().foo(1, inc1(i)).foo(2, inc1(i));   // OK <-- 2 1
6218     i = 0;  getRef().bar(1, inc2(i)).bar(2, inc2(i));   // OK <-- 2 2
6219 }
6220 
6221 /***************************************************/
6222 // https://issues.dlang.org/show_bug.cgi?id=8396
6223 
6224 void test8396()
6225 {
6226     static int g;
6227 
6228     static extern(C) int bar(int a, int b)
6229     {
6230         //printf("a = %d, b = %d\n", a, b);
6231         assert(b - a == 1);
6232         return ++g;
6233     }
6234     static auto getFunc(int n)
6235     {
6236         assert(++g == n);
6237         return &bar;
6238     }
6239 
6240     static struct Tuple { int _a, _b; }
6241     static Tuple foo(int n)
6242     {
6243         assert(++g == n);
6244         return Tuple(1, 2);
6245     }
6246 
6247     g = 0;
6248     assert(bar(foo(1).tupleof) == 2);
6249 
6250     g = 0;
6251     assert(getFunc(1)(foo(2).tupleof) == 3);
6252 }
6253 
6254 /***************************************************/
6255 
6256 enum E160 : ubyte { jan = 1 }
6257 
6258 struct D160
6259 {
6260     short _year  = 1;
6261     E160 _month = E160.jan;
6262     ubyte _day   = 1;
6263 
6264     this(int year, int month, int day) pure
6265     {
6266         _year  = cast(short)year;
6267         _month = cast(E160)month;
6268         _day   = cast(ubyte)day;
6269     }
6270 }
6271 
6272 struct T160
6273 {
6274     ubyte _hour;
6275     ubyte _minute;
6276     ubyte _second;
6277 
6278     this(int hour, int minute, int second = 0) pure
6279     {
6280         _hour   = cast(ubyte)hour;
6281         _minute = cast(ubyte)minute;
6282         _second = cast(ubyte)second;
6283     }
6284 }
6285 
6286 struct DT160
6287 {
6288     D160 _date;
6289     T160 _tod;
6290 
6291     this(int year, int month, int day,
6292          int hour = 0, int minute = 0, int second = 0) pure
6293     {
6294         _date = D160(year, month, day);
6295         _tod = T160(hour, minute, second);
6296     }
6297 }
6298 
6299 void foo160(DT160 dateTime)
6300 {
6301     printf("test7 year %d, day %d\n", dateTime._date._year, dateTime._date._day);
6302     assert(dateTime._date._year == 1999);
6303     assert(dateTime._date._day == 6);
6304 }
6305 
6306 void test160()
6307 {
6308     auto dateTime = DT160(1999, 7, 6, 12, 30, 33);
6309     printf("test5 year %d, day %d\n", dateTime._date._year, dateTime._date._day);
6310     assert(dateTime._date._year == 1999);
6311     assert(dateTime._date._day == 6);
6312     foo160(DT160(1999, 7, 6, 12, 30, 33));
6313 }
6314 
6315 /***************************************************/
6316 // https://issues.dlang.org/show_bug.cgi?id=8437
6317 
6318 class Cgi8437
6319 {
6320     struct PostParserState {
6321         UploadedFile piece;
6322     }
6323 
6324     static struct UploadedFile {
6325         string contentFilename;
6326     }
6327 }
6328 
6329 /***************************************************/
6330 // https://issues.dlang.org/show_bug.cgi?id=8665
6331 
6332 auto foo8665a(bool val)
6333 {
6334     if (val)
6335         return 42;
6336     else
6337         return 1.5;
6338 }
6339 auto foo8665b(bool val)
6340 {
6341     if (!val)
6342         return 1.5;
6343     else
6344         return 42;
6345 }
6346 
6347 void test8665()
6348 {
6349     static assert(is(typeof(foo8665a(true))  == double));
6350     static assert(is(typeof(foo8665b(false)) == double));
6351     assert(foo8665a(true) == 42); // assertion failure
6352     assert(foo8665b(true) == 42); // assertion failure
6353     assert(foo8665a(false) == 1.5);
6354     assert(foo8665b(false) == 1.5);
6355 
6356     static assert(foo8665a(true) == 42);
6357     static assert(foo8665b(true) == 42);
6358     static assert(foo8665a(false) == 1.5);
6359     static assert(foo8665b(false) == 1.5);
6360 }
6361 
6362 /***************************************************/
6363 
6364 int foo8108(int, int);
6365 
6366 int foo8108(int a, int b)
6367 {
6368     return a + b;
6369 }
6370 
6371 void test8108()
6372 {
6373     foo8108(1,2);
6374 }
6375 
6376 /***************************************************/
6377 // https://issues.dlang.org/show_bug.cgi?id=8360
6378 
6379 struct Foo8360
6380 {
6381     int value = 0;
6382     int check = 1337;
6383 
6384     this(int value)
6385     {
6386         assert(0);
6387         this.value = value;
6388     }
6389 
6390     ~this()
6391     {
6392         assert(0);
6393         assert(check == 1337);
6394     }
6395 
6396     string str()
6397     {
6398         assert(0);
6399         return "Foo";
6400     }
6401 }
6402 
6403 Foo8360 makeFoo8360()
6404 {
6405     assert(0);
6406     return Foo8360(2);
6407 }
6408 
6409 void test8360()
6410 {
6411     size_t length = 0;
6412 
6413     // The message part 'makeFoo().str()' should not be evaluated at all.
6414     assert(length < 5, makeFoo8360().str());
6415 }
6416 
6417 /***************************************************/
6418 // https://issues.dlang.org/show_bug.cgi?id=8361
6419 
6420 struct Foo8361
6421 {
6422     string bar = "hello";
6423     ~this() {}
6424 }
6425 
6426 void test8361()
6427 {
6428     assert(true, Foo8361().bar);
6429 }
6430 
6431 /***************************************************/
6432 // https://issues.dlang.org/show_bug.cgi?id=6141
6433 // https://issues.dlang.org/show_bug.cgi?id=8526
6434 
6435 void test6141()
6436 {
6437     static void takeADelegate(void delegate()) {}
6438     auto items = new int[1];
6439     items[0] = 17;
6440     foreach (ref item; items)
6441     {
6442         // both asserts fail
6443         assert(item == 17);
6444         assert(&item == items.ptr);
6445 
6446         takeADelegate({ auto x = &item; });
6447     }
6448 
6449     foreach(ref val; [3])
6450     {
6451         auto dg = { int j = val; };
6452         assert(&val != null); // Assertion failure
6453         assert(val == 3);
6454     }
6455 
6456     static void f(lazy int) {}
6457     int i = 0;
6458     auto dg = { int j = i; };
6459     foreach(ref val; [3])
6460     {
6461         f(val);
6462         assert(&val != null); // Assertion failure
6463         assert(val == 3);
6464     }
6465 }
6466 
6467 void test8526()
6468 {
6469     static void call(void delegate() dg) { dg(); }
6470 
6471     foreach (i, j; [0])
6472     {
6473         call({
6474             assert(i == 0); // fails, i is corrupted
6475         });
6476     }
6477 
6478     foreach (n; 0..1)
6479     {
6480         call({
6481             assert(n == 0); // fails, n is corrupted
6482         });
6483     }
6484 }
6485 
6486 /***************************************************/
6487 
6488 template ParameterTuple(alias func)
6489 {
6490     static if(is(typeof(func) P == __parameters))
6491         alias P ParameterTuple;
6492     else
6493         static assert(0);
6494 }
6495 
6496 int foo161(ref float y);
6497 
6498 void test161()
6499 {
6500     alias PT = ParameterTuple!foo161;
6501     auto x = __traits(identifier, PT);
6502     assert(x == "y");
6503 }
6504 
6505 /***************************************************/
6506 // https://issues.dlang.org/show_bug.cgi?id=7175
6507 
6508 void test7175()
6509 {
6510     struct S { ubyte[0] arr; }
6511     S s;
6512     assert(s.arr.ptr !is null);
6513     assert(cast(void*)s.arr.ptr is cast(void*)&s);
6514 }
6515 
6516 /***************************************************/
6517 // https://issues.dlang.org/show_bug.cgi?id=8819
6518 
6519 void test8819()
6520 {
6521     void[1] sa1 = (void[1]).init;
6522     assert((cast(ubyte*)sa1.ptr)[0] == 0);
6523 
6524     void[4] sa4 = [cast(ubyte)1,cast(ubyte)2,cast(ubyte)3,cast(ubyte)4];
6525     assert((cast(ubyte*)sa4.ptr)[0] == 1);
6526     assert((cast(ubyte*)sa4.ptr)[1] == 2);
6527     assert((cast(ubyte*)sa4.ptr)[2] == 3);
6528     assert((cast(ubyte*)sa4.ptr)[3] == 4);
6529 
6530     auto sa22 = (void[2][2]).init;
6531     static assert(sa22.sizeof == ubyte.sizeof * 2 * 2);
6532     ubyte[4]* psa22 = cast(ubyte[4]*)sa22.ptr;
6533     assert((*psa22)[0] == 0);
6534     assert((*psa22)[1] == 0);
6535     assert((*psa22)[2] == 0);
6536     assert((*psa22)[3] == 0);
6537 }
6538 
6539 /***************************************************/
6540 // https://issues.dlang.org/show_bug.cgi?id=8897
6541 
6542 class C8897
6543 {
6544     static mixin M8897!(int);
6545     static class causesAnError  {}
6546 }
6547 
6548 template M8897 ( E ) { }
6549 
6550 /***************************************************/
6551 // https://issues.dlang.org/show_bug.cgi?id=8917
6552 
6553 void test8917()
6554 {
6555     int[3] a;
6556     int[3] a2;
6557     int[3] b = a[] + a2[];
6558 }
6559 
6560 /***************************************************/
6561 // https://issues.dlang.org/show_bug.cgi?id=8945
6562 
6563 struct S8945 // or `class`, or `union`
6564 {
6565     struct S0(T) { int i; }
6566     struct S1(T) { this(int){} }
6567 }
6568 
6569 void test8945()
6570 {
6571     auto cs0a = const S8945.S0!int();  // ok
6572     auto cs0b = const S8945.S0!int(1); // ok
6573     auto cs1  = const S8945.S1!int(1); // ok
6574 
6575     auto s0a = S8945.S0!int();  // Error: struct S0 does not overload ()
6576     auto s0b = S8945.S0!int(1); // Error: struct S0 does not overload ()
6577     auto s1  = S8945.S1!int(1); // Error: struct S1 does not overload ()
6578 }
6579 
6580 /***************************************************/
6581 
6582 struct S162
6583 {
6584     static int generateMethodStubs( Class )()
6585     {
6586         int text;
6587 
6588         foreach( m; __traits( allMembers, Class ) )
6589         {
6590             static if( is( typeof( mixin( m ) ) ) && is( typeof( mixin( m ) ) == function ) )
6591             {
6592                 pragma(msg, __traits( getOverloads, Class, m ));
6593             }
6594         }
6595 
6596         return text;
6597     }
6598 
6599     enum int ttt = generateMethodStubs!( S162 )();
6600 
6601     float height();
6602     int get( int );
6603     int get( long );
6604     void clear();
6605 
6606     void draw( int );
6607     void draw( long );
6608 }
6609 
6610 /***************************************************/
6611 
6612 void test163() {
6613     static class C { int x; int y; }
6614 
6615     immutable C c = new C();
6616     shared C c2 = new C();
6617     shared const C c3 = new C();
6618 
6619     class D { int x; int y; }
6620     immutable D d;
6621     assert(!__traits(compiles, d = new D()));
6622 
6623     static struct S { int x; int y; }
6624 
6625     immutable S* s = new S();
6626     shared S* s2 = new S();
6627     shared const S* s3 = new S();
6628 
6629     shared S* s4;
6630     assert(__traits(compiles, s4 = new immutable(S)()));
6631 
6632     struct T { int x; int y; }
6633     immutable T* t;
6634     assert(!__traits(compiles, t = new T()));
6635 
6636     immutable int* pi = new int();
6637     immutable void* pv = new int();
6638 
6639     immutable int[] ai = new int[1];
6640     immutable void[] av = new int[2];
6641 }
6642 
6643 /***************************************************/
6644 struct S9000
6645 { ubyte i = ubyte.max; }
6646 
6647 enum E9000 = S9000.init;
6648 
6649 /***************************************************/
6650 
6651 mixin template DefineCoreType(string type)
6652 {
6653     struct Faulty
6654     {
6655         static int x;
6656 
6657         static void instance()
6658         {
6659             x = 3;
6660         }
6661 
6662         X164!() xxx;
6663     }
6664 }
6665 
6666 mixin DefineCoreType!("");
6667 
6668 
6669 mixin template A164()
6670 {
6671     static this()
6672     {
6673     }
6674 }
6675 
6676 struct X164()
6677 {
6678     mixin A164!();
6679 }
6680 
6681 
6682 /***************************************************/
6683 // https://issues.dlang.org/show_bug.cgi?id=9428
6684 
6685 void test9428()
6686 {
6687     int[2][] items = [[1, 2]];
6688     int[2] x = [3, 4];
6689 
6690     auto r1 = items ~ [x];
6691     assert(r1.length == 2);
6692     assert(r1[0][0] == 1);
6693     assert(r1[0][1] == 2);
6694     assert(r1[1][0] == 3);
6695     assert(r1[1][1] == 4);
6696 
6697     auto r2 = items ~ x;
6698     assert(r2.length == 2);
6699     assert(r2[0][0] == 1);
6700     assert(r2[0][1] == 2);
6701     assert(r2[1][0] == 3);
6702     assert(r2[1][1] == 4);
6703 
6704     auto r3 = [x] ~ items;
6705     assert(r3.length == 2);
6706     assert(r3[0][0] == 3);
6707     assert(r3[0][1] == 4);
6708     assert(r3[1][0] == 1);
6709     assert(r3[1][1] == 2);
6710 
6711     auto r4 = x ~ items;
6712     assert(r4.length == 2);
6713     assert(r4[0][0] == 3);
6714     assert(r4[0][1] == 4);
6715     assert(r4[1][0] == 1);
6716     assert(r4[1][1] == 2);
6717 }
6718 
6719 /***************************************************/
6720 // https://issues.dlang.org/show_bug.cgi?id=9477
6721 
6722 template Tuple9477(T...) { alias T Tuple9477; }
6723 template Select9477(bool b, T, U) { static if (b) alias T Select9477; else alias U Select9477; }
6724 
6725 void test9477()
6726 {
6727     static bool isEq (T1, T2)(T1 s1, T2 s2) { return s1 == s2; }
6728     static bool isNeq(T1, T2)(T1 s1, T2 s2) { return s1 != s2; }
6729 
6730     // Must be outside the loop due to http://d.puremagic.com/issues/show_bug.cgi?id=9748
6731     int order;
6732     // Must be outside the loop due to http://d.puremagic.com/issues/show_bug.cgi?id=9756
6733     auto checkOrder(bool dyn, uint expected)()
6734     {
6735         assert(order==expected);
6736         order++;
6737         // Use temporary ("v") to work around http://d.puremagic.com/issues/show_bug.cgi?id=9402
6738         auto v = cast(Select9477!(dyn, string, char[1]))"a";
6739         return v;
6740     }
6741 
6742     foreach (b1; Tuple9477!(false, true))
6743         foreach (b2; Tuple9477!(false, true))
6744         {
6745             version (D_PIC) {} else version (D_PIE) {}  else // Work around http://d.puremagic.com/issues/show_bug.cgi?id=9754
6746             {
6747                 assert( isEq (cast(Select9477!(b1, string, char[0]))"" , cast(Select9477!(b2, string, char[0]))""  ));
6748                 assert(!isNeq(cast(Select9477!(b1, string, char[0]))"" , cast(Select9477!(b2, string, char[0]))""  ));
6749 
6750                 assert(!isEq (cast(Select9477!(b1, string, char[0]))"" , cast(Select9477!(b2, string, char[1]))"a" ));
6751                 assert( isNeq(cast(Select9477!(b1, string, char[0]))"" , cast(Select9477!(b2, string, char[1]))"a" ));
6752             }
6753 
6754             assert( isEq (cast(Select9477!(b1, string, char[1]))"a", cast(Select9477!(b2, string, char[1]))"a" ));
6755             assert(!isNeq(cast(Select9477!(b1, string, char[1]))"a", cast(Select9477!(b2, string, char[1]))"a" ));
6756 
6757             assert(!isEq (cast(Select9477!(b1, string, char[1]))"a", cast(Select9477!(b2, string, char[1]))"b" ));
6758             assert( isNeq(cast(Select9477!(b1, string, char[1]))"a", cast(Select9477!(b2, string, char[1]))"b" ));
6759 
6760             assert(!isEq (cast(Select9477!(b1, string, char[1]))"a", cast(Select9477!(b2, string, char[2]))"aa"));
6761             assert( isNeq(cast(Select9477!(b1, string, char[1]))"a", cast(Select9477!(b2, string, char[2]))"aa"));
6762 
6763             // Note: order of evaluation was not followed before this patch
6764             // (thus, the test below will fail without the patch).
6765             // Although the specification mentions that as implementation-defined behavior,
6766             // I understand that this isn't by design, but rather an inconvenient aspect of DMD
6767             // that has been moved to the specification.
6768             order = 0;
6769             bool result = checkOrder!(b1, 0)() == checkOrder!(b2, 1)();
6770             assert(result);
6771             assert(order == 2);
6772         }
6773 
6774     // need largest natural alignment to avoid unaligned access on
6775     // some architectures, double in this case.
6776     align(8) ubyte[64] a1, a2;
6777     foreach (T; Tuple9477!(void, ubyte, ushort, uint, ulong, char, wchar, dchar, float, double))
6778     {
6779         auto s1 = cast(T[])(a1[]);
6780         auto s2 = cast(T[])(a2[]);
6781         assert(s1 == s2);
6782         a2[$-1]++;
6783         assert(s1 != s2);
6784         assert(s1[0..$-1]==s2[0..$-1]);
6785         a2[$-1]--;
6786     }
6787 }
6788 
6789 /***************************************************/
6790 // https://issues.dlang.org/show_bug.cgi?id=9504
6791 
6792 struct Bar9504
6793 {
6794     template Abc(T)
6795     {
6796         T y;
6797     }
6798 
6799     enum size_t num = 123;
6800 
6801     class Def {}
6802 }
6803 
6804 template GetSym9504(alias sym) { static assert(__traits(isSame, sym, Bar9504.Abc)); }
6805 template GetExp9504(size_t n) { static assert(n == Bar9504.num); }
6806 template GetTyp9504(T) { static assert(is(T == Bar9504.Def)); }
6807 
6808 alias GetSym9504!(typeof(Bar9504.init).Abc) X9504; // NG
6809 alias GetExp9504!(typeof(Bar9504.init).num) Y9504; // NG
6810 alias GetTyp9504!(typeof(Bar9504.init).Def) Z9504;
6811 
6812 Bar9504 test9504()
6813 {
6814     alias GetSym9504!(typeof(return).Abc) V9504; // NG
6815     alias GetExp9504!(typeof(return).num) W9504; // NG
6816     alias GetTyp9504!(typeof(return).Def) X9504;
6817     return Bar9504();
6818 }
6819 
6820 /***************************************************/
6821 // https://issues.dlang.org/show_bug.cgi?id=9538
6822 
6823 void test9538()
6824 {
6825     void*[1] x;
6826     auto ti = typeid(x.ptr);
6827 }
6828 
6829 /***************************************************/
6830 // https://issues.dlang.org/show_bug.cgi?id=9539
6831 
6832 void test9539()
6833 {
6834     void f(int** ptr)
6835     {
6836         assert(**ptr == 10);
6837     }
6838     int* p = new int;
6839     *p = 10;
6840     int*[1] x = [p];
6841     f(&x[0]);
6842 
6843     int*[] arr = [null];
6844     static assert(!__traits(compiles, p = arr));    // bad!
6845 }
6846 
6847 /***************************************************/
6848 // https://issues.dlang.org/show_bug.cgi?id=9700
6849 
6850 mixin template Proxy9700(alias a)
6851 {
6852     auto ref opOpAssign(string op, V)(V v) { return a += v; }  // NG
6853   //auto ref opOpAssign(string op, V)(V v) { a += v; } // OK
6854 }
6855 struct MyInt9700
6856 {
6857     int value;
6858     invariant() { assert(value >= 0); }
6859     mixin Proxy9700!value;
6860 }
6861 void test9700()
6862 {
6863     MyInt9700 a = { 2 };
6864     a *= 3;   // object.Error: Access Violation
6865 }
6866 
6867 /***************************************************/
6868 // https://issues.dlang.org/show_bug.cgi?id=9834
6869 
6870 struct Event9834
6871 {
6872     void delegate() dg;
6873     void set(void delegate() h) pure { dg = h; }  // AV occurs
6874     void call() { dg(); }
6875 }
6876 void test9834()
6877 {
6878     Event9834 ev;
6879     auto a = new class
6880     {
6881         Object o;
6882         this()
6883         {
6884             o = new Object;
6885             ev.set((){ o.toString(); });
6886         }
6887     };
6888     ev.call();
6889 }
6890 
6891 /***************************************************/
6892 // https://issues.dlang.org/show_bug.cgi?id=9859
6893 
6894 void test9859(inout int[] arr)
6895 {
6896     auto dg1 = { foreach (i, e; arr) { } };
6897     dg1();
6898 
6899     void foo() { auto v = arr; auto w = arr[0]; }
6900     void bar(inout int i) { auto v = arr[i]; }
6901 
6902     auto dg2 =
6903     {
6904         auto dg =
6905         {
6906             void foo(T)()
6907             {
6908                 auto dg =
6909                 {
6910                     auto dg =
6911                     {
6912                         auto v = arr;
6913                     };
6914                 };
6915             }
6916             foo!int;
6917         };
6918     };
6919 
6920     void qux(T)()
6921     {
6922         auto v = arr;
6923         auto dg1 = { auto v = arr; };
6924         auto dg2 =
6925         {
6926             auto dg =
6927             {
6928                 auto v = arr;
6929             };
6930         };
6931     }
6932     qux!int;
6933 }
6934 
6935 /***************************************************/
6936 // https://issues.dlang.org/show_bug.cgi?id=9912
6937 
6938 template TypeTuple9912(Stuff...)
6939 {
6940     alias Stuff TypeTuple9912;
6941 }
6942 
6943 struct S9912
6944 {
6945     int i;
6946     alias TypeTuple9912!i t;
6947 
6948     void testA() {
6949         auto x = t;
6950     }
6951 
6952     void testB() {
6953         auto x = t;
6954     }
6955 }
6956 
6957 /***************************************************/
6958 // https://issues.dlang.org/show_bug.cgi?id=9883
6959 
6960 struct S9883
6961 {
6962     @property size_t p9883(T)() { return 0; }
6963 }
6964 
6965 @property size_t p9883(T)() { return 0; }
6966 
6967 void test9883()
6968 {
6969     S9883 s;
6970     auto n1 = p9883!int; // OK
6971     auto n2 = s.p9883!int; // OK
6972     auto a1 = new int[p9883!int]; // Error: need size of rightmost array, not type p!(int)
6973     auto a2 = new int[s.p9883!int]; // Error: no property 'p!(int)' for type 'S'
6974 }
6975 
6976 
6977 /***************************************************/
6978 // https://issues.dlang.org/show_bug.cgi?id=10091
6979 
6980 struct S10091
6981 {
6982     enum e = "a";
6983 }
6984 
6985 void test10091()
6986 {
6987     auto arr = cast(ubyte[1]) S10091.e;
6988 }
6989 
6990 /***************************************************/
6991 
6992 void test12824()
6993 {
6994 label:
6995     static if (0)
6996     {
6997     }
6998 }
6999 
7000 /***************************************************/
7001 // https://issues.dlang.org/show_bug.cgi?id=9130
7002 
7003 class S9130 { void bar() { } }
7004 
7005 import core.stdc.stdio : printf;
7006 
7007 struct Function
7008 {
7009     int[] ai = [1,2,3];
7010 }
7011 
7012 @property void meta(alias m)()
7013 {
7014     static Function md;
7015     printf("length = %zd\n", md.ai.length);
7016     printf("ptr = %p\n", md.ai.ptr);
7017     md.ai[0] = 0;
7018 }
7019 
7020 void test9130()
7021 {
7022     meta!(__traits(getOverloads, S9130, "bar")[0]);
7023     meta!(S9130.bar);
7024 }
7025 
7026 /***************************************************/
7027 // https://issues.dlang.org/show_bug.cgi?id=10390
7028 
7029 class C10390 { this() { this.c = this; } C10390 c; }
7030 const c10390 = new C10390();
7031 pragma(msg, c10390);
7032 
7033 /***************************************************/
7034 // https://issues.dlang.org/show_bug.cgi?id=10542
7035 
7036 class B10542
7037 {
7038     this() nothrow pure @safe { }
7039 }
7040 
7041 class D10542 : B10542
7042 {
7043 }
7044 
7045 void test10542() nothrow pure @safe
7046 {
7047     new D10542;
7048 }
7049 
7050 /***************************************************/
7051 // https://issues.dlang.org/show_bug.cgi?id=10539
7052 
7053 void test10539()
7054 {
7055     int[2][2] a;
7056     int* p1 = a.ptr.ptr;    // OK <- error
7057     int* p2 = (*a.ptr).ptr; // OK
7058     assert(p1 is p2);
7059 }
7060 
7061 /***************************************************/
7062 
7063 struct TimeOfDay
7064 {
7065     ubyte h, m, s;
7066 }
7067 
7068 __gshared byte glob;
7069 
7070 struct DateTime
7071 {
7072     this(ubyte _d, ubyte _m, ubyte _y, TimeOfDay _tod = TimeOfDay.init)
7073     {
7074         d = _d;
7075         m = _m;
7076         y = _y;
7077         tod = _tod;
7078     }
7079     TimeOfDay tod;
7080     ubyte d, m, y;
7081 }
7082 
7083 
7084 void test10634()
7085 {
7086     glob = 123;
7087     DateTime date1 = DateTime(0, 0, 0);
7088     DateTime date2;
7089     assert(date1 == date2);
7090 }
7091 
7092 /***************************************************/
7093 
7094 immutable(char)[4] bar7254(int i)
7095 {
7096     if (i)
7097     {
7098         immutable(char)[4] r; return r;
7099     }
7100     else
7101         return "1234";
7102 }
7103 
7104 void test7254()
7105 {
7106     assert(bar7254(0) == "1234");
7107 }
7108 
7109 /***************************************************/
7110 
7111 struct S11075() { int x = undefined_expr; }
7112 
7113 class C11075() { int x = undefined_expr; }
7114 
7115 interface I11075() { enum int x = undefined_expr; }
7116 
7117 void test11075()
7118 {
7119     static assert(!is(typeof(S11075!().x)));
7120     static assert(!is(typeof(S11075!().x)));
7121 
7122     static assert(!is(typeof(C11075!().x)));
7123     static assert(!is(typeof(C11075!().x)));
7124 
7125     static assert(!is(typeof(I11075!().x)));
7126     static assert(!is(typeof(I11075!().x)));
7127 }
7128 
7129 /***************************************************/
7130 // https://issues.dlang.org/show_bug.cgi?id=11181
7131 
7132 void test11181()
7133 {
7134     auto a = ["a", "b"];
7135 
7136     static assert(!is(typeof([a, "x"])));
7137     static assert(!is(typeof(true ? a : "x")));
7138 
7139     static assert(!is(typeof(true ? a[0 .. $] : "x")));
7140     static assert(!is(typeof([a[0 .. $], "x"])));
7141 }
7142 
7143 /***************************************************/
7144 // https://issues.dlang.org/show_bug.cgi?id=11317
7145 
7146 void test11317()
7147 {
7148     auto ref uint fun()
7149     {
7150         return 0;
7151     }
7152 
7153     void test(ref uint x) {}
7154     static assert(__traits(compiles, test(fun())));
7155 
7156     assert(fun() == 0);
7157 }
7158 
7159 /***************************************************/
7160 // https://issues.dlang.org/show_bug.cgi?id=11888
7161 
7162 void test11888()
7163 {
7164     static long val;
7165 
7166     static ubyte* foo(size_t* len)
7167     {
7168         *len = val.sizeof;
7169         return cast(ubyte*)&val;
7170     }
7171 
7172     size_t size;
7173     ubyte[] t = foo(&size)[0..size];
7174     assert(t.ptr is cast(void*)&val);
7175     assert(t.length == 8);
7176 
7177     // regression test
7178     int[3] sa1 = [1,2,3];
7179     int[1] sa2 = sa1[1..2]; // convert slice to Tsarray
7180     assert(sa2.length == 1);
7181     assert(sa2[0] == 2);
7182 }
7183 
7184 /***************************************************/
7185 // https://issues.dlang.org/show_bug.cgi?id=12036
7186 
7187 template T12036(alias a)
7188 {
7189     string value;
7190 }
7191 
7192 struct S12036
7193 {
7194     auto fun() { }
7195     mixin T12036!fun;
7196 }
7197 
7198 void test12036()
7199 {
7200     S12036 s;
7201     assert(s.value == "");
7202 }
7203 
7204 /***************************************************/
7205 // https://issues.dlang.org/show_bug.cgi?id=12153
7206 
7207 void test12153()
7208 {
7209     int[1] i, j;
7210     bool b = true;
7211     (b ? i : j)[] = [4];
7212     assert(i == [4]);
7213 
7214     // regression test
7215     int[1][1] k, l;
7216     (b ? k : l)[0..1][0..1] = [4];
7217     assert(k == [[4]]);
7218 }
7219 
7220 /***************************************************/
7221 // https://issues.dlang.org/show_bug.cgi?id=12498
7222 
7223 string a12498()
7224 {
7225     string b;
7226     while (b) { }
7227     for (; b; ) { }
7228     return "";
7229 }
7230 
7231 void test12498()
7232 {
7233     enum t = a12498();
7234     string x = t;
7235 }
7236 
7237 /***************************************************/
7238 // https://issues.dlang.org/show_bug.cgi?id=12900
7239 
7240 struct A12900
7241 {
7242     char[1] b;
7243 }
7244 
7245 void test12900()
7246 {
7247     A12900 c;
7248     if (*c.b.ptr)
7249         return;
7250 }
7251 
7252 /***************************************************/
7253 // https://issues.dlang.org/show_bug.cgi?id=12929
7254 
7255 struct Foo12929
7256 {
7257     union { }
7258     int var;
7259 }
7260 
7261 struct Bar12929
7262 {
7263     struct { }
7264     int var;
7265 }
7266 
7267 /***************************************************/
7268 // https://issues.dlang.org/show_bug.cgi?id=12937
7269 
7270 void test12937()
7271 {
7272     void[1] sa2 = cast(void[])[cast(ubyte)1];   // ICE!
7273     assert((cast(ubyte[])sa2[])[0] == 1);
7274 }
7275 
7276 /***************************************************/
7277 // https://issues.dlang.org/show_bug.cgi?id=13154
7278 
7279 void test13154()
7280 {
7281     int[3] ints      = [2   , 1   , 0   , 1   ][0..3];
7282     float[3] floats0 = [2f  , 1f  , 0f  , 1f  ][0..3];
7283     float[3] floats1 = [2.0 , 1.0 , 0.0 , 1.0 ][0..3];  // fails!
7284     float[3] floats2 = [2.0f, 1.0f, 0.0f, 1.0f][0..3];
7285     assert(ints == [2, 1, 0]);
7286     assert(floats0 == [2, 1, 0]);
7287     assert(floats1 == [2, 1, 0]); // fail!
7288     assert(floats1 != [0, 0, 0]); // fail!
7289     assert(floats2 == [2, 1, 0]);
7290 }
7291 
7292 /***************************************************/
7293 // https://issues.dlang.org/show_bug.cgi?id=13437
7294 
7295 ubyte[4] foo13437() { return [1,2,3,4]; }
7296 
7297 void test13437()
7298 {
7299     auto n = cast(ubyte[4])foo13437()[];  // OK <- ICE: e2ir.c 4616
7300     static assert(is(typeof(n) == ubyte[4]));
7301     assert(n == [1,2,3,4]);
7302 }
7303 
7304 /***************************************************/
7305 // https://issues.dlang.org/show_bug.cgi?id=13472
7306 
7307 class A13472
7308 {
7309     int a;
7310 }
7311 
7312 void test13472()
7313 {
7314     A13472[] test;
7315     test.length = 4;
7316     auto b = test[0..2] ~ null ~ test[2..$];
7317     assert(b.length == 5);
7318 }
7319 
7320 /***************************************************/
7321 // https://issues.dlang.org/show_bug.cgi?id=13476
7322 
7323 template ParameterTypeTuple13476(func...)
7324 {
7325     static if (is(typeof(*func[0]) P == function))
7326         alias ParameterTypeTuple13476 = P;
7327     else
7328         static assert(0, "argument has no parameters");
7329 }
7330 
7331 int flag13476;
7332 
7333 __gshared extern(C) void function(int) nothrow someFunc13476 = &Stub13476!someFunc13476;
7334 
7335 extern(C) auto Stub13476(alias func)(ParameterTypeTuple13476!func args)
7336 {
7337     ++flag13476;
7338     extern(C) void function(int) nothrow impl = (i) { };
7339     return (func = impl)(args);
7340 }
7341 
7342 __gshared extern(C) void function(int) nothrow  someFunc13476Alt = &Stub13476Alt!someFunc13476AltP;
7343 __gshared extern(C) void function(int) nothrow* someFunc13476AltP = &someFunc13476Alt;
7344 
7345 extern(C) auto Stub13476Alt(alias func)(int args) nothrow
7346 {
7347     ++flag13476;
7348     extern(C) void function(int) nothrow impl = (i) {};
7349     return (*func = impl)(args);
7350 }
7351 
7352 void test13476()
7353 {
7354     assert(flag13476 == 0);
7355 
7356     someFunc13476(42);
7357     assert(flag13476 == 1);
7358     someFunc13476(43);
7359     assert(flag13476 == 1);
7360 
7361     someFunc13476Alt(42);
7362     assert(flag13476 == 2);
7363     someFunc13476Alt(43);
7364     assert(flag13476 == 2);
7365 }
7366 
7367 /***************************************************/
7368 // https://issues.dlang.org/show_bug.cgi?id=14038
7369 
7370 static immutable ubyte[string] wordsAA14038;
7371 shared static this()
7372 {
7373     wordsAA14038["zero"] = 0;
7374 }
7375 
7376 /***************************************************/
7377 // https://issues.dlang.org/show_bug.cgi?id=14192
7378 
7379 void test14192()
7380 {
7381     shared int[int] map;
7382     map[1] = 1;
7383 }
7384 
7385 /***************************************************/
7386 // https://issues.dlang.org/show_bug.cgi?id=13720
7387 
7388 struct FracSec13720
7389 {
7390     this(int hnsecs) {}
7391 }
7392 
7393 struct SysTime13720
7394 {
7395     this(TimeOfDay13720 dateTime, FracSec13720 fracSec)
7396     {
7397     }
7398 }
7399 
7400 struct TimeOfDay13720
7401 {
7402     ~this() { }
7403 }
7404 
7405 void assertThrown13720(T)(lazy T) {}
7406 
7407 void test13720()
7408 {
7409     assertThrown13720(SysTime13720(TimeOfDay13720.init, FracSec13720(-1)));
7410 }
7411 
7412 /***************************************************/
7413 // https://issues.dlang.org/show_bug.cgi?id=13952
7414 
7415 struct Reg13952
7416 {
7417     ubyte type;
7418     ubyte regNo;
7419     ushort size;
7420 }
7421 
7422 struct Imm13952
7423 {
7424     ulong imm;
7425 }
7426 
7427 struct Opnd13952
7428 {
7429     union
7430     {
7431         Reg13952 reg; // size == 4
7432         Imm13952 imm; // size == 8
7433     }
7434     ubyte tag;
7435 
7436     this(Reg13952 r) { reg = r; }
7437 }
7438 
7439 Opnd13952 opnd13952(Reg13952 reg)
7440 {
7441     return Opnd13952(reg);
7442 }
7443 
7444 void test13952()
7445 {
7446     Reg13952 reg;
7447     auto op = opnd13952(reg);
7448     auto buf = (cast(ubyte*)&op)[0 .. op.sizeof];
7449     //debug
7450     //{
7451     //    import std.stdio;
7452     //    writefln("op.reg = [%(%02x %)]", (cast(ubyte*)&op.reg)[0 .. Reg13952.sizeof]);
7453     //    writefln("op.imm = [%(%02x %)]", (cast(ubyte*)&op.imm)[0 .. Imm13952.sizeof]);
7454     //}
7455     foreach (e; buf) assert(e == 0);
7456 }
7457 
7458 /***************************************************/
7459 // https://issues.dlang.org/show_bug.cgi?id=14165
7460 
7461 class Foo14165
7462 {
7463     @disable this();
7464     this(int i) {}
7465 }
7466 
7467 /***************************************************/
7468 // https://issues.dlang.org/show_bug.cgi?id=13985
7469 
7470 interface I13985
7471 {
7472     void m1();
7473     void m2();
7474     void m3();
7475 
7476     final void mf()
7477     {
7478         m3();
7479     }
7480 }
7481 
7482 class C13985 : I13985
7483 {
7484     void m1() {}
7485     void m2() {}
7486     void m3() {}
7487 }
7488 
7489 class D13985 : C13985
7490 {
7491     void ml()
7492     {
7493         super.mf();
7494     }
7495 }
7496 
7497 void test13985()
7498 {
7499     auto d = new D13985();
7500     d.ml();
7501 }
7502 
7503 /***************************************************/
7504 // https://issues.dlang.org/show_bug.cgi?id=14211
7505 
7506 extern(C++) // all derived classes won't have invariants
7507 class B14211
7508 {
7509     void func()
7510     {
7511     }
7512 }
7513 
7514 final class C14211 : B14211
7515 {
7516 }
7517 
7518 void test14211()
7519 {
7520     auto c = new C14211();
7521     *cast(void**)c = null;
7522     c.func();   // called without vtbl access
7523 }
7524 
7525 /***************************************************/
7526 // https://issues.dlang.org/show_bug.cgi?id=14552
7527 
7528 template map14552(fun...)
7529 {
7530     template AppliedReturnType(alias f)
7531     {
7532         alias typeof(f(0)) AppliedReturnType;
7533     }
7534 
7535     auto map14552(int[] r)
7536     {
7537         assert(!is(AppliedReturnType!fun));
7538         return MapResult14552!fun();
7539     }
7540 }
7541 
7542 struct MapResult14552(alias fun)
7543 {
7544     @property front()
7545     {
7546         fun(0);
7547     }
7548 }
7549 
7550 class Outer14552
7551 {
7552     auto test()
7553     {
7554         [1].map14552!(j => new Inner);
7555     }
7556     class Inner {}
7557 }
7558 
7559 /***************************************************/
7560 // https://issues.dlang.org/show_bug.cgi?id=14853
7561 
7562 struct Queue14853(T)
7563 {
7564     struct Node
7565     {
7566         T mfPayload = T.init;
7567         union
7568         {
7569                    typeof(this)*  mfPrev;
7570             shared(typeof(this)*) mfShPrev;
7571         }
7572         union
7573         {
7574                    typeof(this)*  mfNext;
7575             shared(typeof(this)*) mfShNext;
7576         }
7577     }
7578 
7579     Node root;
7580 
7581     void pfPut(T v, Node* r = null)
7582     {
7583         shared n = new Node(v);    // problem!
7584     }
7585 }
7586 
7587 void test14853()
7588 {
7589     auto b1 = new Queue14853!uint;
7590 }
7591 
7592 /********************************************************/
7593 // https://issues.dlang.org/show_bug.cgi?id=15045
7594 
7595 void test15045()
7596 {
7597     void testName(T, bool r, string name)()
7598     {
7599         T t;
7600 
7601         static assert(r ==          is(typeof(mixin("T."~name))));
7602         static assert(r ==          is(typeof(mixin("t."~name))));
7603         static assert(r == __traits(compiles, mixin("T."~name)));
7604         static assert(r == __traits(compiles, mixin("t."~name)));
7605         static assert(r == mixin("__traits(compiles, T."~name~")"));
7606         static assert(r == mixin("__traits(compiles, t."~name~")"));
7607 
7608         static assert(r ==                       __traits(hasMember, T, name) );
7609         static assert(r ==                       __traits(hasMember, t, name) );
7610         static assert(r == __traits(compiles,    __traits(getMember, T, name) ));
7611         static assert(r == __traits(compiles,    __traits(getMember, t, name) ));
7612         static assert(r == __traits(compiles, __traits(getOverloads, T, name) ));
7613         static assert(r == __traits(compiles, __traits(getOverloads, t, name) ));
7614     }
7615     void test(T, bool r)()
7616     {
7617         testName!(T, r, "__ctor")();
7618         testName!(T, r, "__dtor")();
7619         testName!(T, r, "__xdtor")();
7620         testName!(T, r, "__postblit")();
7621         testName!(T, r, "__xpostblit")();
7622     }
7623 
7624     static struct X
7625     {
7626         this(int) {}
7627         this(this) {}
7628         ~this() {}
7629     }
7630 
7631     static struct S1
7632     {
7633         auto opDispatch(string name, A...)(A args) { }
7634     }
7635     static struct S2
7636     {
7637         X get() { return X(); };
7638         alias get this;
7639     }
7640     static struct S3
7641     {
7642         X opDot() { return X(); };
7643     }
7644 
7645     test!(X, true)();
7646     test!(S1, false)();
7647     test!(S2, false)();
7648     test!(S3, false)();
7649 }
7650 
7651 /***************************************************/
7652 // https://issues.dlang.org/show_bug.cgi?id=15116
7653 
7654 alias TypeTuple15116(T...) = T;
7655 
7656 template Mix15116()
7657 {
7658     TypeTuple15116!(int, int) tup;
7659 }
7660 
7661 struct S15116
7662 {
7663     mixin Mix15116 mix;
7664 }
7665 
7666 void test15116()
7667 {
7668     S15116 s;
7669     auto x1 = s.tup;        // OK
7670     auto x2 = s.mix.tup;    // OK <- NG
7671 }
7672 
7673 /***************************************************/
7674 // https://issues.dlang.org/show_bug.cgi?id=15117
7675 
7676 template Mix15117()
7677 {
7678     int y = { typeof(this)* s; return s ? s.mix.y : 0; }();
7679 }
7680 
7681 struct S15117
7682 {
7683     int x = { typeof(this)* s; return s ? s.x : 0; }(); // OK
7684 
7685     mixin Mix15117 mix;     // OK <- NG
7686 }
7687 
7688 /***************************************************/
7689 // https://issues.dlang.org/show_bug.cgi?id=15126
7690 
7691 struct Json15126
7692 {
7693     ubyte[16] m_data;
7694     int opDispatch(string prop)() const { return 0; }
7695     int opDispatch(string prop)() { return 0; }
7696 }
7697 
7698 template isCustomSerializable15126(T)
7699 {
7700     enum isCustomSerializable15126 = T.init.toRepresentation();
7701 }
7702 
7703 alias bug15126 = isCustomSerializable15126!Json15126;
7704 
7705 /***************************************************/
7706 // https://issues.dlang.org/show_bug.cgi?id=15141
7707 
7708 class A15141
7709 {
7710     abstract void method();
7711 }
7712 
7713 class B15141 : A15141 { }
7714 
7715 void test15141()
7716 {
7717     auto a = Object.factory(__MODULE__ ~ ".A15141");
7718     assert(a is null);
7719     auto b = Object.factory(__MODULE__ ~ ".B15141");
7720     assert(b is null); // OK <- oops
7721 }
7722 
7723 /***************************************************/
7724 // https://issues.dlang.org/show_bug.cgi?id=15366
7725 
7726 enum E15366 : bool { A, B };
7727 
7728 struct S15366
7729 {
7730     void func1(E15366 e) {}
7731 
7732     void func2(E15366 a, E15366 b)
7733     {
7734         func1(cast(E15366)(a && b));
7735         func1(cast(E15366)(a || b));
7736 
7737         auto x1 = cast(E15366)(a && b);
7738         auto x2 = cast(E15366)(a || b);
7739     }
7740 }
7741 
7742 /***************************************************/
7743 // https://issues.dlang.org/show_bug.cgi?id=15369
7744 
7745 struct MsgTable15369
7746 {
7747     const(char)[] ident;
7748     const(char)* name;
7749 };
7750 
7751 MsgTable15369[] msgTable15369 =
7752 [
7753     { "empty", "" },
7754 ];
7755 
7756 void test15369()
7757 {
7758     auto id = msgTable15369[0].ident;
7759     auto p = msgTable15369[0].name;
7760 
7761     // a string literal "" should be zero-terminated
7762     assert(*p == '\0');
7763 }
7764 
7765 void test15638()
7766 {
7767     class A {}
7768     class B : A {}
7769     class C : A {}
7770 
7771     B b;
7772     C c;
7773     const(B) cb;
7774     const(C) cc;
7775     immutable(B) ib;
7776     immutable(C) ic;
7777 
7778     // Common type for const derived classes
7779     auto constCommon = true ? cb : cc;
7780     static assert(is(typeof(constCommon) == const(A)));
7781 
7782     // Common type for immutable derived classes
7783     auto immutableCommon = true ? ib : ic;
7784     static assert(is(typeof(immutableCommon) == immutable(A)));
7785 
7786     // Common type for mixed const/immutable derived classes
7787     auto mixed1 = true ? cb : ic;
7788     static assert(is(typeof(mixed1) == const(A)));
7789     auto mixed2 = true ? ib : cc;
7790     static assert(is(typeof(mixed2) == const(A)));
7791 
7792     // Common type for mixed mutable/immutable derived classes
7793     auto mixed3 = true ? b : ic;
7794     static assert(is(typeof(mixed3) == const(A)));
7795     auto mixed4 = true ? ib : c;
7796     static assert(is(typeof(mixed4) == const(A)));
7797 
7798     // Array literal type deduction
7799     auto arr1 = [ new immutable(B), new C ];
7800     auto arr2 = [ new B,            new const(C) ];
7801     auto arr3 = [ new immutable(B), new immutable(C) ];
7802     static assert(is(typeof(arr1) == const(A)[]));
7803     static assert(is(typeof(arr2) == const(A)[]));
7804     static assert(is(typeof(arr3) == immutable(A)[]));
7805 }
7806 
7807 /***************************************************/
7808 // https://issues.dlang.org/show_bug.cgi?id=15961
7809 
7810 struct SliceOverIndexed15961(T)
7811 {
7812     enum assignableIndex = T.init;
7813 }
7814 
7815 struct Grapheme15961
7816 {
7817     SliceOverIndexed15961!Grapheme15961 opSlice()
7818     {
7819         assert(0);
7820     }
7821 
7822     struct
7823     {
7824         ubyte* ptr_;
7825     }
7826 }
7827 
7828 /***************************************************/
7829 // https://issues.dlang.org/show_bug.cgi?id=16022
7830 
7831 bool test16022()
7832 {
7833     enum Type { Colon, Comma }
7834     Type type;
7835     return type == Type.Comma;
7836 }
7837 
7838 bool test16022_structs()
7839 {
7840     struct A
7841     {
7842         int i;
7843         string s;
7844     }
7845 
7846     enum Type { Colon = A(0, "zero"), Comma = A(1, "one") }
7847     Type type;
7848     return type == Type.Comma;
7849 }
7850 
7851 /***************************************************/
7852 // https://issues.dlang.org/show_bug.cgi?id=16233
7853 
7854 enum valueConvertible(T1, T2) = blah;
7855 
7856 struct Checked(T, Hook)
7857 {
7858     bool opEquals(U)(Checked!(U, Hook) rhs)
7859     {
7860         alias R = typeof(payload + rhs.payload);
7861         static if (valueConvertible!(T, R))
7862         {
7863         }
7864         return false;
7865     }
7866 }
7867 
7868 void test16233()
7869 {
7870     Checked!(Checked!(int, void), void) x1;
7871 }
7872 
7873 /***************************************************/
7874 // https://issues.dlang.org/show_bug.cgi?id=16466
7875 
7876 void test16466()
7877 {
7878     static struct S
7879     {
7880         real r;
7881     }
7882     real r;
7883     printf("S.alignof: %zx, r.alignof: %zx\n", S.alignof, r.alignof);
7884     assert(S.alignof == r.alignof);
7885 }
7886 
7887 /***************************************************/
7888 
7889 // https://issues.dlang.org/show_bug.cgi?id=16408
7890 
7891 char[1] SDL_GetKeyName_buffer;
7892 
7893 const(char)[] SDL_GetKeyName(char k)
7894 {
7895     pragma(inline, false);
7896     SDL_GetKeyName_buffer[0] = k;
7897     return SDL_GetKeyName_buffer[];
7898 }
7899 
7900 void formattedWrite(const(char)[] strW, const(char)[] strA, const(char)[] strC)
7901 {
7902     pragma(inline, false);
7903 
7904     assert(strW == "W");
7905     assert(strA == "A");
7906     assert(strC == "C");
7907 }
7908 
7909 void test16408()
7910 {
7911     pragma(inline, false);
7912     formattedWrite(
7913         SDL_GetKeyName('W').idup,
7914         SDL_GetKeyName('A').idup,
7915         SDL_GetKeyName('C').idup
7916     );
7917 }
7918 
7919 /***************************************************/
7920 // https://issues.dlang.org/show_bug.cgi?id=17349
7921 
7922 void test17349()
7923 {
7924     static struct S
7925     {
7926         int bar(void delegate(ref int*)) { return 1; }
7927         int bar(void delegate(ref const int*)) const { return 2; }
7928     }
7929 
7930     void dg1(ref int*) { }
7931     void dg2(ref const int*) { }
7932     S s;
7933     int i;
7934     i = s.bar(&dg1);
7935     assert(i == 1);
7936     i = s.bar(&dg2);
7937     assert(i == 2);
7938 }
7939 
7940 /***************************************************/
7941 // https://issues.dlang.org/show_bug.cgi?id=17915
7942 
7943 void test17915()
7944 {
7945     static class MyClass
7946     {
7947         S17915!MyClass m_member;
7948     }
7949 }
7950 
7951 struct S17915(T)
7952 {
7953     T owner;
7954 }
7955 
7956 void test18232()
7957 {
7958     static struct Canary
7959     {
7960         int x = 0x900D_900D;
7961     }
7962     union U
7963     {
7964         Canary method()
7965         {
7966             Canary c;
7967             return c;
7968         }
7969     }
7970     U u;
7971     assert(u.method() == Canary.init);
7972 }
7973 
7974 /***************************************************/
7975 
7976 int main()
7977 {
7978     test1();
7979     test2();
7980     test4();
7981     test5();
7982     test6();
7983     test7();
7984     test8();
7985     test9();
7986     test10();
7987     test11();
7988     test12();
7989     test13();
7990     test14();
7991     test15();
7992     test16();
7993     test17();
7994     test18();
7995     test19();
7996     test20();
7997     test21();
7998     test22();
7999     test23();
8000     test24();
8001     test25();
8002     test26();
8003     test27();
8004     test28();
8005     test29();
8006     test30();
8007     test31();
8008     test32();
8009     test33();
8010     test34();
8011     test35();
8012     test36();
8013     test37();
8014     test38();
8015     test39();
8016     test40();
8017     test41();
8018     test42();
8019     test43();
8020     test44();
8021     test45();
8022     test46();
8023     test47();
8024     test48();
8025     test49();
8026     test796();
8027     test50();
8028     test51();
8029     test52();
8030     test53();
8031     test54();
8032     test55();
8033     test56();
8034     test57();
8035     test58();
8036 
8037     test60();
8038     test61();
8039     test62();
8040     test63();
8041     test64();
8042     test65();
8043     test66();
8044     test67();
8045     test68();
8046     test69();
8047     test70();
8048 
8049     test5785();
8050     test72();
8051     test73();
8052     test74();
8053     test75();
8054     test76();
8055     test77();
8056     test78();
8057     test79();
8058     test80();
8059     test81();
8060     test82();
8061     test83();
8062     test3559();
8063     test84();
8064     test85();
8065     test2006();
8066     test8442();
8067     test86();
8068     test87();
8069     test2486();
8070     test5554();
8071     test88();
8072     test7545();
8073     test89();
8074     test90();
8075     test91();
8076     test92();
8077     test4536();
8078     test93();
8079     test94();
8080     test95();
8081     test5403();
8082     test96();
8083     test97();
8084     test98();
8085     test99();
8086     test100();
8087     test101();
8088 
8089     test103();
8090     test104();
8091     test105();
8092     test3927();
8093     test107();
8094 
8095     test109();
8096 
8097     test111();
8098 
8099     test113();
8100 
8101     test115();
8102     test116();
8103     test117();
8104     test3822();
8105     test6545();
8106     test118();
8107     test5081();
8108 
8109     test120();
8110     test10724();
8111     test122();
8112     test123();
8113     test124();
8114     test125();
8115     test6763();
8116 
8117     test127();
8118     test128();
8119     test1891();
8120     test129();
8121     test130();
8122     test1064();
8123     test131();
8124     test132();
8125     test133();
8126     test134();
8127     test135();
8128     test136();
8129     test137();
8130     test138();
8131     test1962();
8132     test139();
8133     test140();
8134     test141();
8135     test6317();
8136     test142();
8137     test143();
8138     test144();
8139     test145();
8140     test146();
8141     test147();
8142     test6685();
8143     test148();
8144     test149();
8145     test2356();
8146     test13652();
8147     test11238();
8148     test2540();
8149     test14348();
8150     test150();
8151     test151();
8152     test152();
8153     test153();
8154     test154();
8155     test155();
8156     test156();
8157     test658();
8158     test4258();
8159     test4539();
8160     test4963();
8161     test4031();
8162     test5437();
8163     test6230();
8164     test6264();
8165     test6284();
8166     test6295();
8167     test6293();
8168     test5046();
8169     test1471();
8170     test6335();
8171     test1687();
8172     test6228();
8173     test3733();
8174     test4392();
8175     test7942();
8176     test6220();
8177     test5799();
8178     test157();
8179     test6473();
8180     test6630();
8181     test6690();
8182     test2953();
8183     test2997();
8184     test4423();
8185     test4647();
8186     test5696();
8187     test6084();
8188     test6488();
8189     test6565();
8190     test6836();
8191     test6837();
8192     test6927();
8193     test6733();
8194     test6813();
8195     test6859();
8196 
8197     test6910();
8198     test6902();
8199     test6330();
8200     test6868();
8201     test2856();
8202     test3091();
8203     test6056();
8204     test6356();
8205     test7073();
8206     test7104();
8207     test7150();
8208     test7160();
8209     test7168();
8210     test7170();
8211     test7196();
8212     test7285();
8213     test14737();
8214     test7321();
8215     test3282();
8216     test7534();
8217     test7534cov();
8218     test7618();
8219     test7621();
8220     test11417();
8221     test7682();
8222     test7735();
8223     test7823();
8224     test7871();
8225     test7906();
8226     test7907();
8227     test12503();
8228     test8004();
8229     test8064();
8230     test8105();
8231     test159();
8232     test12824();
8233     test8283();
8234     test13182();
8235     test8269();
8236     test8395();
8237     test13427();
8238     test5749();
8239     test8396();
8240     test160();
8241     test8665();
8242     test8108();
8243     test8360();
8244     test9577();
8245     test6141();
8246     test199();
8247     test8526();
8248     test161();
8249     test7175();
8250     test8819();
8251     test8917();
8252     test8945();
8253     test11805();
8254     test14192();
8255     test163();
8256     test9428();
8257     test9477();
8258     test9538();
8259     test9700();
8260     test9834();
8261     test13947();
8262     test9883();
8263     test10091();
8264     test9130();
8265     test10542();
8266     test10539();
8267     test10634();
8268     test15080();
8269     test7254();
8270     test13468();
8271     test11075();
8272     test11181();
8273     test11317();
8274     test11888();
8275     test12036();
8276     test12153();
8277     test12937();
8278     test13154();
8279     test13437();
8280     test13472();
8281     test13476();
8282     test13720();
8283     test13952();
8284     test13985();
8285     test14211();
8286     test15141();
8287     test15369();
8288     test15638();
8289     test16233();
8290     test16466();
8291     test16408();
8292     test17349();
8293     test17915();
8294     test18232();
8295 
8296     printf("Success\n");
8297     return 0;
8298 }
8299