Merge dmd upstream e2fe2687b
[official-gcc.git] / gcc / testsuite / gdc.test / runnable / nested.d
blob98261ff4ab4875d393b4c0544a6ae6d26b3d0244
1 // REQUIRED_ARGS:
3 import core.stdc.stdio;
5 /*******************************************/
7 int bar(int a)
9 int foo(int b) { return b + 1; }
11 return foo(a);
14 void test1()
16 assert(bar(3) == 4);
19 /*******************************************/
21 int bar2(int a)
23 static int c = 4;
25 int foo(int b) { return b + c + 1; }
27 return foo(a);
30 void test2()
32 assert(bar2(3) == 8);
36 /*******************************************/
38 int bar3(int a)
40 static int foo(int b) { return b + 1; }
42 return foo(a);
45 void test3()
47 assert(bar3(3) == 4);
50 /*******************************************/
52 int bar4(int a)
54 static int c = 4;
56 static int foo(int b) { return b + c + 1; }
58 return foo(a);
61 void test4()
63 assert(bar4(3) == 8);
67 /*******************************************/
69 int bar5(int a)
71 int c = 4;
73 int foo(int b) { return b + c + 1; }
75 return c + foo(a);
78 void test5()
80 assert(bar5(3) == 12);
84 /*******************************************/
86 int bar6(int a)
88 int c = 4;
90 int foob(int b) { return b + c + 1; }
91 int fooa(int b) { return foob(c + b) * 7; }
93 return fooa(a);
96 void test6()
98 assert(bar6(3) == 84);
102 /*******************************************/
104 int bar7(int a)
106 static int c = 4;
108 static int foob(int b) { return b + c + 1; }
110 int function(int) fp = &foob;
112 return fp(a);
115 void test7()
117 assert(bar7(3) == 8);
120 /*******************************************/
122 int bar8(int a)
124 int c = 4;
126 int foob(int b) { return b + c + 1; }
128 int delegate(int) fp = &foob;
130 return fp(a);
133 void test8()
135 assert(bar8(3) == 8);
139 /*******************************************/
141 struct Abc9
143 int a;
144 int b;
145 int c = 7;
147 int bar(int x)
149 Abc9 *foo() { return &this; }
151 Abc9 *p = foo();
152 assert(p == &this);
153 return p.c + x;
157 void test9()
159 Abc9 x;
161 assert(x.bar(3) == 10);
164 /*******************************************/
166 class Abc10
168 int a;
169 int b;
170 int c = 7;
172 int bar(int x)
174 Abc10 foo() { return this; }
176 Abc10 p = foo();
177 assert(p == this);
178 return p.c + x;
183 void test10()
185 Abc10 x = new Abc10();
187 assert(x.bar(3) == 10);
191 /*******************************************/
193 class Collection
195 int[3] array;
197 void opApply(void delegate(int) fp)
199 for (int i = 0; i < array.length; i++)
200 fp(array[i]);
204 int func11(Collection c)
206 int max = int.min;
208 void comp_max(int i)
210 if (i > max)
211 max = i;
214 c.opApply(&comp_max);
215 return max;
218 void test11()
220 Collection c = new Collection();
222 c.array[0] = 7;
223 c.array[1] = 26;
224 c.array[2] = 25;
226 int m = func11(c);
227 assert(m == 26);
231 /*******************************************/
233 void SimpleNestedFunction ()
235 int nest () { return 432; }
237 assert (nest () == 432);
238 int delegate () func = &nest;
239 assert (func () == 432);
242 void AccessParentScope ()
244 int value = 9;
246 int nest () { assert (value == 9); return 9; }
248 assert (nest () == 9);
251 void CrossNestedScope ()
253 int x = 45;
255 void foo () { assert (x == 45); }
256 void bar () { int z = 16; foo (); }
257 bar ();
260 void BadMultipleNested ()
262 int x;
264 void foo ()
266 void bar ()
268 //erroneous x = 4; // Should fail.
273 /* This one kind of depends upon memory layout. GlobalScopeSpoof should
274 be called with no "this" pointer; this is trying to ensure that
275 everything is working properly. Of course, in the DMD calling
276 convention it'll fail if the caller passes too much/little data. */
278 void GlobalScopeSpoof (int x, int y)
280 assert (x == y && y == 487);
283 void GlobalScope ()
285 void bar () { GlobalScopeSpoof (487, 487); }
286 bar ();
289 class TestClass
291 int x = 6400;
293 void foo ()
295 void bar () { assert (x == 6400); }
296 bar ();
300 void test12()
302 SimpleNestedFunction ();
303 AccessParentScope ();
304 CrossNestedScope ();
305 GlobalScope ();
306 (new TestClass).foo ();
310 /*******************************************/
312 void test13()
314 struct Abc
316 int x = 3;
317 int y = 4;
320 Abc a;
322 assert(a.x == 3 && a.y == 4);
326 /*******************************************/
328 void test14()
330 struct Abc
332 int x = 3;
333 int y = 4;
335 int foo() { return y; }
338 Abc a;
340 assert(a.foo() == 4);
344 /*******************************************/
346 void test15()
348 static int z = 5;
350 struct Abc
352 int x = 3;
353 int y = 4;
355 int foo() { return y + z; }
358 Abc a;
360 assert(a.foo() == 9);
364 /*******************************************/
366 void test16()
368 static int z = 5;
370 static class Abc
372 int x = 3;
373 int y = 4;
375 int foo() { return y + z; }
378 Abc a = new Abc();
380 assert(a.foo() == 9);
384 /*******************************************/
386 void test17()
388 int function(int x) fp;
390 fp = function int(int y) { return y + 3; };
391 assert(fp(7) == 10);
394 /*******************************************/
396 void test18()
398 static int a = 3;
399 int function(int x) fp;
401 fp = function int(int y) { return y + a; };
402 assert(fp(7) == 10);
405 /*******************************************/
407 void test19()
409 int a = 3;
411 int delegate(int x) fp;
413 fp = delegate int(int y) { return y + a; };
414 assert(fp(7) == 10);
418 /*******************************************/
420 class Collection20
422 int[3] array;
424 void opApply(void delegate(int) fp)
426 for (int i = 0; i < array.length; i++)
427 fp(array[i]);
431 int func20(Collection20 c)
433 int max = int.min;
435 c.opApply(delegate(int i) { if (i > max) max = i; });
436 return max;
439 void test20()
441 Collection20 c = new Collection20();
443 c.array[0] = 7;
444 c.array[1] = 26;
445 c.array[2] = 25;
447 int m = func20(c);
448 assert(m == 26);
452 /*******************************************/
454 int bar21(int a)
456 int c = 3;
458 int foo(int b)
460 b += c; // 4 is added to b
461 c++; // bar.c is now 5
462 return b + c; // 12 is returned
464 c = 4;
465 int i = foo(a); // i is set to 12
466 return i + c; // returns 17
469 void test21()
471 int i = bar21(3); // i is assigned 17
472 assert(i == 17);
475 /*******************************************/
477 void foo22(void delegate() baz)
479 baz();
482 void bar22(int i)
484 int j = 14;
485 printf("%d,%d\n",i,j);
487 void fred()
489 printf("%d,%d\n",i,j);
490 assert(i == 12 && j == 14);
493 fred();
494 foo22(&fred);
497 void test22()
499 bar22(12);
503 /*******************************************/
505 void frelled(void delegate() baz)
507 baz();
510 class Foo23
512 void bar(int i)
514 int j = 14;
515 printf("%d,%d\n",i,j);
517 void fred()
519 printf("%d,%d\n",i,j);
520 assert(i == 12);
521 assert(j == 14);
524 frelled(&fred);
528 void test23()
530 Foo23 f = new Foo23();
532 f.bar(12);
536 /*******************************************/
538 void delegate () function (int x) store24;
540 void delegate () zoom24(int x)
542 return delegate void () { };
545 void test24()
547 store24 = &zoom24;
548 store24 (1) ();
552 /*******************************************/
554 void test25()
556 delegate() { printf("stop the insanity!\n"); }();
557 delegate() { printf("stop the insanity! 2\n"); }();
560 /*******************************************/
562 alias bool delegate(int) callback26;
565 bool foo26(callback26 a)
567 return a(12);
570 class Bar26
572 int func(int v)
574 printf("func(v=%d)\n", v);
575 foo26(delegate bool(int a)
577 printf("%d %d\n",a,v); return true;
578 assert(a == 12);
579 assert(v == 15);
580 assert(0);
581 } );
582 return v;
587 void test26()
589 Bar26 b = new Bar26();
591 b.func(15);
595 /*******************************************/
597 class A27
599 uint myFunc()
601 uint myInt = 13;
602 uint mySubFunc()
604 return myInt;
606 return mySubFunc();
610 void test27()
612 A27 myInstance = new A27;
613 int i = myInstance.myFunc();
614 printf("%d\n", i);
615 assert(i == 13);
619 /*******************************************/
621 void Foo28(void delegate() call)
623 call();
626 class Bar28
628 int func()
630 int count = 0;
632 Foo28(delegate void() { ++count; } );
633 return count;
637 void test28()
639 Bar28 b = new Bar28();
640 int i = b.func();
641 assert(i == 1);
645 /*******************************************/
647 class Foo29
649 void Func(void delegate() call)
651 for(int i = 0; i < 10; ++i)
652 call();
656 class Bar29
658 int Func()
660 int count = 0;
661 Foo29 ic = new Foo29();
663 ic.Func(delegate void() { ++count; } );
664 return count;
668 void test29()
670 Bar29 b = new Bar29();
671 int i = b.Func();
672 assert(i == 10);
675 /*******************************************/
677 struct Foo30
679 int[] arr;
682 void Func30(Foo30 bar)
684 void InnerFunc(int x, int y)
686 int a = bar.arr[y]; // Ok
688 if(bar.arr[y]) // Access violation
693 InnerFunc(5,5);
697 void test30()
699 Foo30 abc;
701 abc.arr.length = 10;
702 Func30(abc);
706 /*******************************************/
708 void call31(int d, void delegate(int d) f)
710 assert(d == 100 || d == 200);
711 printf("d = %d\n", d);
712 f(d);
715 void test31()
717 call31(100, delegate void(int d1)
719 printf("d1 = %d\n", d1);
720 assert(d1 == 100);
721 call31(200, delegate void(int d2)
723 printf("d1 = %d\n", d1);
724 printf("d2 = %d\n", d2);
725 assert(d1 == 100);
726 assert(d2 == 200);
732 /*******************************************/
734 void call32(int d, void delegate(int d) f)
736 assert(d == 100 || d == 200);
737 printf("d = %d\n", d);
738 f(d);
741 void test32()
743 call32(100, delegate void(int d1)
745 int a = 3;
746 int b = 4;
747 printf("d1 = %d, a = %d, b = %d\n", d1, a, b);
748 assert(a == 3);
749 assert(b == 4);
750 assert(d1 == 100);
752 call32(200, delegate void(int d2)
754 printf("d1 = %d, a = %d\n", d1, a);
755 printf("d2 = %d, b = %d\n", d2, b);
756 assert(a == 3);
757 assert(b == 4);
758 assert(d1 == 100);
759 assert(d2 == 200);
765 /*******************************************/
767 void test33()
769 extern (C) int Foo1(int a, int b, int c)
771 assert(a == 1);
772 assert(b == 2);
773 assert(c == 3);
774 return 1;
777 extern (D) int Foo2(int a, int b, int c)
779 assert(a == 1);
780 assert(b == 2);
781 assert(c == 3);
782 return 2;
785 extern (Windows) int Foo3(int a, int b, int c)
787 assert(a == 1);
788 assert(b == 2);
789 assert(c == 3);
790 return 3;
793 extern (Pascal) int Foo4(int a, int b, int c)
795 assert(a == 1);
796 assert(b == 2);
797 assert(c == 3);
798 return 4;
801 assert(Foo1(1, 2, 3) == 1);
802 assert(Foo2(1, 2, 3) == 2);
803 assert(Foo3(1, 2, 3) == 3);
804 assert(Foo4(1, 2, 3) == 4);
806 printf("test33 success\n");
809 /*******************************************/
811 class Foo34
813 int x;
815 class Bar
817 int y;
819 int delegate() getDelegate()
821 assert(y == 8);
822 auto i = sayHello();
823 assert(i == 23);
824 return &sayHello;
827 Bar bar;
829 int sayHello()
831 printf("Hello\n");
832 assert(x == 47);
833 return 23;
836 this()
838 x = 47;
839 bar = new Bar();
840 bar.y = 8;
844 void test34()
846 Foo34 foo = new Foo34();
847 int delegate() saydg = foo.bar.getDelegate();
848 printf("This should print Hello:\n");
849 auto i = saydg();
850 assert(i == 23);
853 /*******************************************/
855 class Foo35
857 int x = 42;
858 void bar()
860 int y = 43;
861 new class Object
863 this()
865 //writefln("x = %s", x);
866 //writefln("y = %s", y);
867 assert(x == 42);
868 assert(y == 43);
869 //static assert(is(typeof(this.outer) == void*)); // Bugzilla 14442
870 static assert(is(typeof(this.outer) == Foo35)); // Bugzilla 15839
876 void test35()
878 Foo35 f = new Foo35();
879 f.bar();
882 /*******************************************/
884 class Foo36
886 int x = 42;
887 this()
889 int y = 43;
890 new class Object
892 this()
894 //writefln("x = %s", x);
895 //writefln("y = %s", y);
896 assert(x == 42);
897 assert(y == 43);
903 void test36()
905 Foo36 f = new Foo36();
908 /*******************************************/
910 class Foo37
912 int x = 42;
913 void bar()
915 int y = 43;
916 void abc()
918 new class Object
920 this()
922 //writefln("x = %s", x);
923 //writefln("y = %s", y);
924 assert(x == 42);
925 assert(y == 43);
930 abc();
934 void test37()
936 Foo37 f = new Foo37();
937 f.bar();
940 /*******************************************/
942 void test38()
944 int status = 3;
946 int delegate() foo()
948 class C
950 int dg()
952 return ++status;
956 C c = new C();
958 return &c.dg;
961 int delegate() bar = foo();
963 if(status != 3)
965 assert(0);
968 if(bar() != 4)
970 assert(0);
973 if(status != 4)
975 assert(0);
979 /*******************************************/
981 void test39()
983 int status;
985 int delegate() foo()
987 return &(new class
989 int dg()
991 return ++status;
994 ).dg;
997 int delegate() bar = foo();
999 if(status != 0)
1001 assert(0);
1004 if(bar() != 1)
1006 assert(0);
1009 if(status != 1)
1011 assert(0);
1015 /*******************************************/
1017 interface I40
1019 void get( string s );
1022 class C40
1024 int a = 4;
1026 void init()
1028 I40 i = new class() I40
1030 void get( string s )
1032 func();
1035 i.get("hello");
1037 void func( ){ assert(a == 4); }
1040 void test40()
1042 C40 c = new C40();
1043 c.init();
1046 /*******************************************/
1048 class C41
1049 { int a = 3;
1051 void init()
1053 class N
1055 void get()
1057 func();
1060 N n = new N();
1061 n.get();
1063 void func()
1065 assert(a == 3);
1070 void test41()
1072 C41 c = new C41();
1073 c.init();
1076 /*******************************************/
1078 class C42
1079 { int a = 3;
1081 void init()
1083 class N
1085 void init()
1087 class M
1089 void get()
1091 func();
1094 M m = new M();
1095 m.get();
1098 N n = new N();
1099 n.init();
1101 void func()
1103 assert(a == 3);
1107 void test42()
1109 C42 c = new C42();
1110 c.init();
1114 /*******************************************/
1116 int foo43(alias X)() { return X; }
1118 void test43()
1120 int x = 3;
1122 void bar()
1124 int y = 4;
1125 assert(foo43!(x)() == 3);
1126 assert(foo43!(y)() == 4);
1129 bar();
1131 assert(foo43!(x)() == 3);
1135 /*******************************************/
1137 class Comb
1141 Comb Foo44(Comb delegate()[] c...)
1143 Comb ec = c[0]();
1144 printf("1ec = %p\n", ec);
1145 ec.toString();
1146 printf("2ec = %p\n", ec);
1147 return ec;
1150 Comb c44;
1152 static this()
1154 c44 = new Comb;
1157 void test44()
1159 c44 = Foo44(Foo44(c44));
1162 /*******************************************/
1164 class Bar45
1166 void test()
1168 a = 4;
1169 Inner i = new Inner;
1170 i.foo();
1173 class Inner
1175 void foo()
1177 assert(a == 4);
1178 Inner i = new Inner;
1179 i.bar();
1182 void bar()
1184 assert(a == 4);
1187 int a;
1190 void test45()
1192 Bar45 b = new Bar45;
1193 assert(b.a == 0);
1194 b.test();
1197 /*******************************************/
1199 class Adapter
1201 int a = 2;
1203 int func()
1205 return 73;
1209 class Foo46
1211 int b = 7;
1213 class AnonAdapter : Adapter
1215 int aa = 8;
1217 this()
1219 assert(b == 7);
1220 assert(aa == 8);
1224 void func()
1226 Adapter a = cast( Adapter )( new AnonAdapter() );
1227 assert(a.func() == 73);
1228 assert(a.a == 2);
1232 void test46()
1234 Foo46 f = new Foo46();
1235 f.func();
1239 /*******************************************/
1241 void test47()
1243 void delegate() test =
1245 struct Foo {int x=3;}
1246 Foo f;
1247 assert(f.x == 3);
1249 test();
1252 /*******************************************/
1254 struct Outer48
1256 class Inner
1258 this(int i) { b = i; }
1259 int b;
1262 int a = 6;
1264 void f()
1266 int nested()
1268 auto x = new Inner(a);
1269 return x.b + 1;
1271 int i = nested();
1272 assert(i == 7);
1277 void test48()
1279 Outer48 s;
1280 s.f();
1283 /*******************************************/
1285 void test49()
1287 int j = 10;
1288 void mainlocal(int x)
1290 printf("mainlocal: j = %d, x = %d\n", j, x);
1291 assert(j == 10);
1292 assert(x == 1);
1295 void fun2()
1297 int k = 20;
1298 void fun2local(int x)
1300 printf("fun2local: k = %d, x = %d\n", k, x);
1301 assert(j == 10);
1302 assert(k == 20);
1303 assert(x == 2);
1306 void fun1()
1308 mainlocal(1);
1309 fun2local(2);
1312 fun1();
1315 fun2();
1318 /*******************************************/
1320 void funa50(alias pred1, alias pred2)()
1322 pred1(1);
1323 pred2(2);
1326 void funb50(alias pred1)()
1327 { int k = 20;
1328 void funb50local(int x)
1330 printf("funb50local: k = %d, x = %d\n", k, x);
1331 assert(k == 20);
1332 assert(x == 2);
1334 funa50!(pred1, funb50local)();
1337 void test50()
1339 int j = 10;
1340 void mainlocal(int x)
1342 printf("mainlocal: j = %d, x = %d\n", j, x);
1343 assert(j == 10);
1344 assert(x == 1);
1346 funb50!(mainlocal)();
1349 /*******************************************/
1351 void funa51(alias pred1, alias pred2)()
1353 pred1(2);
1354 pred2(1);
1357 void funb51(alias pred1)()
1358 { int k = 20;
1359 void funb51local(int x)
1361 printf("funb51local: k = %d, x = %d\n", k, x);
1362 assert(k == 20);
1363 assert(x == 2);
1365 funa51!(funb51local, pred1)();
1368 void test51()
1370 int j = 10;
1371 void mainlocal(int x)
1373 printf("mainlocal: j = %d, x = %d\n", j, x);
1374 assert(j == 10);
1375 assert(x == 1);
1377 funb51!(mainlocal)();
1380 /*******************************************/
1382 C52 c52;
1384 class C52
1386 int index = 7;
1387 void test1(){
1388 printf( "this = %p, index = %d\n", this, index );
1389 assert(index == 7);
1390 assert(this == c52);
1392 void test()
1394 class N
1396 void callI()
1398 printf("test1\n");
1399 test1();
1400 printf("test2\n");
1401 if (index is -1)
1402 { // Access to the outer-super-field triggers the bug
1403 printf("test3\n");
1407 auto i = new N();
1408 i.callI();
1412 void test52()
1414 auto c = new C52;
1415 printf("c = %p\n", c);
1416 c52 = c;
1417 c.test();
1420 /*******************************************/
1422 void foo53(int i)
1424 struct SS
1426 int x,y;
1427 int bar() { return x + i + 1; }
1429 SS s;
1430 s.x = 3;
1431 assert(s.bar() == 11);
1434 void test53()
1436 foo53(7);
1439 /*******************************************/
1441 void test54()
1443 int x = 40;
1444 int fun(int i) { return x + i; }
1446 struct A
1448 int bar(int i) { return fun(i); }
1451 A makeA()
1453 // A a; return a;
1454 return A();
1457 A makeA2()
1459 A a; return a;
1460 //return A();
1463 A a = makeA();
1464 assert(a.bar(2) == 42);
1466 A b = makeA2();
1467 assert(b.bar(3) == 43);
1469 auto c = new A;
1470 assert(c.bar(4) == 44);
1472 /*******************************************/
1474 void test55()
1476 int localvar = 7;
1478 int inner(int delegate(ref int) dg) {
1479 int k = localvar;
1480 return 0;
1483 int a = localvar * localvar; // This modifies the EAX register
1485 foreach (entry; &inner)
1490 /*******************************************/
1491 // 4401
1493 void test4401()
1495 auto foo() {
1496 return 3;
1499 auto bar() nothrow pure {
1500 return 3;
1503 auto baz() @property pure @safe {
1504 return 3;
1507 auto zoo()() @property pure @safe nothrow {
1508 return 3;
1512 /*******************************************/
1514 alias void delegate() dg_t;
1516 void Y(dg_t delegate (dg_t) y)
1518 struct F { void delegate(F) f; }
1520 version (all)
1521 { // generates error
1522 (dg_t delegate(F) a){return a(F((F b){return y(a(b))();})); }
1523 ((F b){return (){return b.f(b);};});
1525 else
1527 auto abc(dg_t delegate(F) a)
1529 return a(F((F b){return y(a(b))();}));
1532 abc((F b){return (){return b.f(b);};});
1537 void test7428(){
1538 dg_t foo(dg_t self)
1540 void bar() { self(); }
1541 return &bar;
1544 Y(&foo);
1547 /*******************************************/
1548 // 4612
1550 struct S4612a(alias x)
1552 void* func() { void* p = &x; return p; }
1555 struct S4612b(alias x)
1557 int i;
1558 void* func() { void* p = &x; return p; }
1561 void test4612()
1563 int a;
1565 auto sa = S4612a!a();
1566 assert(sa.func() == &a);
1568 auto sb = S4612b!(a)();
1569 assert(sb.func() == &a);
1572 /*******************************************/
1574 struct S4841(alias pred)
1576 void unused_func();
1579 void abc4841() {
1580 int w;
1581 S4841!(w) m;
1584 void test4841() {
1585 abc4841();
1588 /*******************************************/
1591 void index7199()
1593 void find()
1595 bool hay()
1597 return true;
1601 find();
1604 void test7199()
1606 index7199();
1609 /*******************************************/
1610 // 7965
1612 void test7965()
1614 int x;
1615 static int* px;
1616 px = &x;
1618 printf("&x = %p in main()\n", &x);
1619 struct S1
1621 char y;
1622 void boom() {
1623 printf("&x = %p in S1.boom()\n", &x);
1624 assert(&x == px);
1625 //x = 42; // makes the struct nested
1628 S1 s1;
1629 s1.boom();
1631 struct S2
1633 this(int n) {
1634 printf("&x = %p in S2.this()\n", &x);
1635 assert(&x == px);
1637 char y;
1639 S2 s2 = S2(10);
1642 struct S7965
1644 string str;
1645 uint unused1, unused2 = 0;
1648 auto f7965(alias fun)()
1650 struct Result
1652 S7965 s;
1653 this(S7965 _s) { s = _s; } // required for the problem
1654 void g() { assert(fun(s.str) == "xa"); }
1657 return Result(S7965("a"));
1660 void test7965a()
1662 string s = "x";
1663 f7965!(a => s ~= a)().g();
1664 assert(s == "xa");
1667 /*******************************************/
1668 // 8188
1670 mixin template Print8188(b...)
1672 int doprint()
1674 return b[0] * b[1];
1678 class A8188
1680 int x, y;
1681 mixin Print8188!(x, y);
1684 void test8188()
1686 auto a = new A8188;
1687 a.x = 2;
1688 a.y = 5;
1689 assert(a.doprint() == 10);
1692 /*******************************************/
1693 // 5082
1695 struct S5082 { float x; }
1697 struct Map5082a(alias fun)
1699 typeof({ return fun(int.init); }()) cache;
1702 struct Map5082b(alias fun)
1704 typeof({ return fun(int.init); }()) cache;
1706 S5082 front(int i) { return fun(i); }
1709 void test5082()
1711 auto temp = S5082(1);
1712 auto func = (int v){ return temp; };
1713 auto map1 = Map5082a!func();
1714 auto map2 = Map5082b!func();
1715 assert(map2.front(1) == temp);
1719 /*******************************************/
1720 // 8194
1722 void test8194()
1724 int foo;
1725 static void bar()
1727 typeof(foo) baz;
1728 static assert(is(typeof(baz) == int));
1732 /*******************************************/
1733 // 8339
1735 template map8339a(fun...)
1737 auto map8339a(Range)(Range r) {
1738 struct Result {
1739 this(double[] input) {}
1741 return Result(r);
1744 template map8339b(fun...)
1746 auto map8339b(Range)(Range r) {
1747 struct Result {
1748 this(double[] input) { fun[0](input.length); }
1750 return Result(r);
1753 template map8339c(fun...)
1755 auto map8339c(Range)(Range r) {
1756 static struct Result {
1757 this(double[] input) {}
1759 return Result(r);
1762 template map8339d(fun...)
1764 auto map8339d(Range)(Range r) {
1765 static struct Result {
1766 this(double[] input) { fun[0](input.length); }
1768 return Result(r);
1771 void copy8339(T)(T x)
1773 T xSaved;
1775 void test8339a()
1777 double[] x;
1778 int n;
1780 // Result has context pointer, so cannot copy
1781 static assert (!is(typeof({ copy8339(map8339a!(a=>a)(x)); })));
1782 static assert (!is(typeof({ copy8339(map8339a!(a=>n)(x)); })));
1784 // same as
1785 static assert (!is(typeof({ copy8339(map8339b!(a=>a)(x)); })));
1786 static assert (!is(typeof({ copy8339(map8339b!(a=>n)(x)); })));
1788 // fun is never instantiated
1789 copy8339(map8339c!(a=>a)(x));
1790 copy8339(map8339c!(a=>n)(x));
1792 // static nested struct doesn't have contest pointer
1793 copy8339(map8339d!(a=>a)(x));
1794 //copy8339(map8339d!(a=>n)(x)); // too strict case
1798 template filter8339(alias pred)
1800 auto filter8339(R)(R r) {
1801 struct Result {
1802 R range;
1803 this(R r) { range = r; }
1804 auto front() { return pred(0); }
1806 return Result(r);
1809 void test8339b()
1811 static makefilter() { int n; return filter8339!(a=>n)([]); }
1813 auto r1 = makefilter();
1814 filter8339!(a=>a)(r1);
1817 void test8339c()
1819 class C(X) { X x; }
1820 class C1 { C!C1 x; }
1821 alias C!C1 C2;
1823 struct Pair { C1 t; C2 u; void func(){} }
1824 Pair pair;
1827 /*******************************************/
1828 // 8704
1830 void check8704(T, int num)()
1832 static if (num == 1) T t0;
1833 static if (num == 2) T t1 = T();
1834 static if (num == 3) T t2 = T(1);
1837 void test8704()
1839 struct S
1841 int n;
1842 void foo(){}
1845 static assert(!is(typeof(check8704!(S, 1)())));
1846 static assert(!is(typeof(check8704!(S, 2)())));
1847 static assert(!is(typeof(check8704!(S, 3)())));
1849 static assert(!__traits(compiles, check8704!(S, 1)()));
1850 static assert(!__traits(compiles, check8704!(S, 2)()));
1851 static assert(!__traits(compiles, check8704!(S, 3)()));
1854 /*******************************************/
1855 // 8923
1857 void test8923a()
1859 int val;
1861 struct S // is nested struct
1863 void foo() { val = 1; } // access to val through the hidden frame pointer
1865 S s1a; s1a.foo();
1866 S s1b = S(); s1b.foo();
1867 S[1] s2a; s2a[0].foo();
1868 S[1] s2b = S(); s2b[0].foo();
1870 static struct U { S s; }
1871 U u1a; u1a.s.foo();
1872 U u1b = U(); u1b.s.foo();
1873 U u1c = U(s1a); u1c.s.foo();
1874 U[1] u2a; u2a[0].s.foo();
1875 U[1] u2b = U(); u2b[0].s.foo();
1876 U[1] u2c = U(s1a); u2c[0].s.foo();
1877 static struct V { S[1] s; }
1878 V v1a; v1a.s[0].foo();
1879 V v1b = V(); v1b.s[0].foo();
1880 V v1c = V(s1a); v1c.s[0].foo();
1881 V[1] v2a; v2a[0].s[0].foo();
1882 V[1] v2b = V(); v2b[0].s[0].foo();
1883 V[1] v2c = V(s1a); v2c[0].s[0].foo();
1885 static struct W { S s; this(S s){ this.s = s; } }
1886 W w1a; w1a.s.foo();
1887 W w1b = W(); w1b.s.foo();
1888 W w1c = W(s1a); w1c.s.foo();
1889 W[1] w2a; w2a[0].s.foo();
1890 W[1] w2b = W(); w2b[0].s.foo();
1891 W[1] w2c = W(s1a); w2c[0].s.foo();
1892 static struct X { S[1] s; this(S s){ this.s[] = s; } }
1893 X x1a; x1a.s[0].foo();
1894 X x1b = X(); x1b.s[0].foo();
1895 X x1c = X(s1a); x1c.s[0].foo();
1896 X[1] x2a; x2a[0].s[0].foo();
1897 X[1] x2b = X(); x2b[0].s[0].foo();
1898 X[1] x2c = X(s1a); x2c[0].s[0].foo();
1900 // Both declarations, Y and Z should raise errors,
1901 // because their ctors don't initialize their field 's'.
1902 static assert(!__traits(compiles, {
1903 static struct Y { S s; this(S){} }
1904 }));
1905 /+ Y y1a; //y1a.s.foo();
1906 Y y1b = Y(); y1b.s.foo();
1907 Y y1c = Y(s1a);//y1c.s.foo();
1908 Y[1] y2a; //y2a[0].s.foo();
1909 Y[1] y2b = Y(); y2b[0].s.foo();
1910 Y[1] y2c = Y(s1a);//y2c[0].s.foo(); +/
1911 static assert(!__traits(compiles, {
1912 static struct Z { S[1] s; this(S){} }
1913 }));
1914 /+ Z z1a; //z1a.s[0].foo();
1915 Z z1b = Z(); z1b.s[0].foo();
1916 Z z1c = Z(s1a);//z1c.s[0].foo();
1917 Z[1] z2a; //z1a.s[0].foo();
1918 Z[1] z2b = Z(); z1b.s[0].foo();
1919 Z[1] z2c = Z(s1a);//z1c.s[0].foo(); // +/
1922 struct Tuple8923(int v, T...)
1924 T field;
1925 static if (v == 1) this(T args) { } // should be an error
1926 static if (v == 2) this(T args) { field = args; }
1927 static if (v == 3) this(U...)(U args) { } // should be an error
1928 static if (v == 4) this(U...)(U args) { field = args; }
1929 //alias field this;
1931 void test8923b()
1933 int val;
1934 struct S { void foo() { val = 1; } }
1936 static assert(!__traits(compiles, Tuple8923!(1, S)(S()) ));
1937 static assert(!__traits(compiles, Tuple8923!(3, S)(S()) ));
1939 auto tup2 = Tuple8923!(2, S)(S());
1940 tup2.field[0].foo(); // correctly initialized
1942 auto tup4 = Tuple8923!(4, S)(S());
1943 tup4.field[0].foo(); // correctly initialized
1946 void test8923c()
1948 int val;
1950 struct S // is nested struct
1952 void foo() { val = 1; } // access to val through the hidden frame pointer
1954 S s1a; s1a.foo();
1955 S s1b = S(); s1b.foo();
1956 S[1] s2a; s2a[0].foo();
1957 S[1] s2b = S(); s2b[0].foo();
1959 // U,V,W,X are nested struct, but should work same as non-nested.
1960 // 1: bare struct object. 2: static array of structs.
1961 // a: default construction.
1962 // b: construction by literal syntax which has no argument.
1963 // c: construction by literal syntax which has one or more arguments.
1965 struct U
1967 S s;
1968 void foo() { val = 2; }
1970 U u1a; u1a.foo(); u1a.s.foo();
1971 U u1b = U(); u1b.foo(); u1b.s.foo();
1972 U u1c = U(s1a); u1c.foo(); u1c.s.foo();
1973 U[1] u2a; u2a[0].foo(); u2a[0].s.foo();
1974 U[1] u2b = U(); u2b[0].foo(); u2b[0].s.foo();
1975 U[1] u2c = U(s1a); u2c[0].foo(); u2c[0].s.foo();
1977 struct V
1979 S[1] s;
1980 void foo() { val = 2; }
1982 V v1a; v1a.foo(); v1a.s[0].foo();
1983 V v1b = V(); v1b.foo(); v1b.s[0].foo();
1984 V v1c = V(s1a); v1c.foo(); v1c.s[0].foo();
1985 V[1] v2a; v2a[0].foo(); v2a[0].s[0].foo();
1986 V[1] v2b = V(); v2b[0].foo(); v2b[0].s[0].foo();
1987 V[1] v2c = V(s1a); v2c[0].foo(); v2c[0].s[0].foo();
1989 struct W
1991 S s;
1992 this(S s) { this.s = s; }
1993 void foo() { val = 2; }
1995 W w1a; w1a.foo(); w1a.s.foo();
1996 W w1b = W(); w1b.foo(); w1b.s.foo();
1997 W w1c = W(s1a); w1c.foo(); w1c.s.foo();
1998 W[1] w2a; w2a[0].foo(); w2a[0].s.foo();
1999 W[1] w2b = W(); w2b[0].foo(); w2b[0].s.foo();
2000 W[1] w2c = W(s1a); w2c[0].foo(); w2c[0].s.foo();
2002 struct X
2004 S[1] s;
2005 this(S s) { this.s[] = s; }
2006 void foo() { val = 2; }
2008 X x1a; x1a.foo(); x1a.s[0].foo();
2009 X x1b = X(); x1b.foo(); x1b.s[0].foo();
2010 X x1c = X(s1a); x1c.foo(); x1c.s[0].foo();
2011 X[1] x2a; x2a[0].foo(); x2a[0].s[0].foo();
2012 X[1] x2b = X(); x2b[0].foo(); x2b[0].s[0].foo();
2013 X[1] x2c = X(s1a); x2c[0].foo(); x2c[0].s[0].foo();
2015 // Both declarations, Y and Z should raise errors,
2016 // because their ctors don't initialize their field 's'.
2017 static assert(!__traits(compiles, {
2018 struct Y1 { S s; this(S){} void foo() { val = 2; } }
2019 }));
2020 static assert(!__traits(compiles, {
2021 struct Y2 { S s; this(T)(S){} void foo() { val = 2; } }
2022 auto y2 = Y2!S(S()); // instantiate ctor
2023 }));
2025 static assert(!__traits(compiles, {
2026 struct Z1 { S[1] s; this(S){} void foo() { val = 2; } }
2027 }));
2028 static assert(!__traits(compiles, {
2029 struct Z2 { S[1] s; this(T)(S){} void foo() { val = 2; } }
2030 auto z2 = Z2!S(S()); // instantiate ctor
2031 }));
2034 /*******************************************/
2035 // 9003
2037 void test9003()
2039 int i;
2040 struct NS {
2041 int n1; // Comment to pass all asserts
2042 int n2; // Uncomment to fail assert on line 19
2043 int f() { return i; }
2046 static struct SS1 {
2047 NS ns;
2049 SS1 ss1;
2050 assert(ss1.ns != NS.init);
2052 static struct SS2 {
2053 NS ns1, ns2;
2055 SS2 ss2;
2056 assert(ss2.ns1 != NS.init); // line 19
2057 assert(ss2.ns2 != NS.init);
2059 static struct SS3 {
2060 int i;
2061 NS ns;
2064 SS3 ss3;
2065 assert(ss3.ns != NS.init);
2067 static struct SS4 {
2068 int i;
2069 NS ns1, ns2;
2072 SS4 ss4;
2073 assert(ss4.ns1 != NS.init); // fails
2074 assert(ss4.ns2 != NS.init); // fails
2077 /*******************************************/
2078 // 9006
2080 void test9006()
2082 int i;
2083 struct NS
2085 int n;
2086 int[3] a; // Uncomment to fail assert on line 20 and pass on line 23
2087 int f() { return i; }
2089 NS ns;
2090 assert(ns != NS.init);
2091 ns = NS.init;
2092 assert(ns == NS.init);
2094 static struct SS { NS ns; }
2095 assert(SS.init.ns == NS.init); // fails
2096 assert(SS.init.ns != NS()); // fails
2098 SS s;
2099 assert(s.ns != NS.init); // line 20
2100 assert(s != SS.init); // fails
2101 s = SS.init;
2102 assert(s.ns == NS.init); // line 23, fails
2103 assert(s == SS.init);
2106 /*******************************************/
2107 // 9035
2109 void test9035()
2111 static struct S {}
2113 void f(T)(auto ref T t)
2115 static assert(!__traits(isRef, t));
2118 f(S.init); // ok, rvalue
2119 f(S()); // ok, rvalue
2121 int i;
2122 struct Nested
2124 int j = 0; void f() { ++i; }
2127 f(Nested()); // ok, rvalue
2128 f(Nested.init); // fails, lvalue
2130 assert(Nested.init.j == 0);
2131 //(ref n) { n.j = 5; }(Nested.init);
2132 assert(Nested.init.j == 0); // fails, j is 5
2135 void test9035a()
2137 int x;
2138 struct S {
2139 // no field
2140 void foo() { x = 1; }
2142 S s1;
2143 S s2 = S();
2144 assert(s1 != S.init); // OK
2145 assert(s2 != S.init); // OK
2146 assert(S() != S.init); // NG -> OK
2149 /*******************************************/
2150 // 9036
2152 void test9036()
2154 static int i;
2155 static struct S
2157 this(this) { ++i; }
2160 S s = S.init;
2161 assert(i == 0); // postblit not called
2162 s = S.init;
2163 assert(i == 0); // postblit not called
2165 int k;
2166 static int j = 0;
2167 struct N
2169 this(this)
2171 ++j;
2172 assert(this.tupleof[$-1] != null); // fails
2174 void f() { ++k; }
2177 N n = N.init;
2178 assert(j == 0); // fails, j = 1, postblit called
2179 n = N.init;
2180 assert(j == 0); // fails, j = 2, postblit called
2183 /*******************************************/
2186 auto fun8863(T)(T* ret) { *ret = T(); }
2188 void test8863()
2190 int x = 1;
2191 struct A
2193 auto f()
2195 assert(x == 1);
2199 A a;
2200 a.f();
2201 fun8863!A(&a);
2202 a.f();
2206 /*******************************************/
2207 // 8774
2209 void popFront8774()
2211 int[20] abc; // smash stack
2214 struct MapResult8774(alias fun)
2216 void delegate() front()
2218 return fun(1);
2222 void test8774() {
2224 int sliceSize = 100;
2226 void delegate() foo( int i )
2228 void delegate() closedPartialSum()
2230 int ii = i ;
2231 void bar()
2233 printf("%d\n", sliceSize);
2234 assert(sliceSize == 100);
2236 return &bar;
2238 return closedPartialSum();
2241 auto threads = MapResult8774!foo();
2243 auto dg = threads.front();
2244 popFront8774();
2246 printf("calling dg()\n");
2247 dg();
2250 /*******************************************/
2252 int Bug8832(alias X)()
2254 return X();
2257 int delegate() foo8832()
2259 int stack;
2260 int heap = 3;
2262 int nested_func()
2264 ++heap;
2265 return heap;
2267 return delegate int() { return Bug8832!(nested_func); };
2270 void test8832()
2272 auto z = foo8832();
2273 auto p = foo8832();
2274 assert(z() == 4);
2275 p();
2276 assert(z() == 5);
2279 /*******************************************/
2280 // 9315
2282 auto test9315()
2284 struct S
2286 int i;
2287 void bar() {}
2289 pragma(msg, S.init.tupleof[$-1]);
2292 /*******************************************/
2293 // 9244
2295 void test9244()
2297 union U {
2298 int i;
2299 @safe int x() { return i; }
2303 /*******************************************/
2304 // 10495
2306 struct X10495
2308 @disable this();
2311 struct Y10495(alias f)
2313 void g() {}
2316 class C10495
2318 X10495 s = X10495.init;
2320 void h()
2322 Y10495!(a => a) st;
2326 /*******************************************/
2327 // 11385
2329 auto map11385(alias fun, R)(R range)
2331 return MapResult11385!(fun, R)(range);
2333 struct MapResult11385(alias fun, R)
2335 R range;
2336 auto front() { return fun(range[0]); }
2338 void test11385()
2340 //import std.algorithm;
2341 static auto fun1(T)(T a) { return a * 2; }
2342 auto fun2(T)(T a) { return a * 2; }
2343 [1].map11385!(a=>fun1(a)); // OK
2344 [1].map11385!(a=>fun2(a)); // NG:XXX is a nested function and cannot be accessed from XXX
2347 /*******************************************/
2349 void xmap(alias g)(int t)
2351 g(t);
2354 enum foo11297 = function (int x)
2356 //int bar(int y) { return x; } xmap!bar(7);
2357 xmap!(y => x)(7);
2360 void xreduce(alias f)()
2362 f(4);
2365 void test11297()
2367 xreduce!foo11297();
2370 /*******************************************/
2371 // 11886
2373 struct Lambda11886(alias fun)
2375 auto opCall(A...)(A args) { return fun(args); }
2377 void test11886()
2379 int n = 10;
2380 Lambda11886!(x => x + n) f;
2381 assert(f(1) == 11); // Line 9
2383 struct NS
2385 auto foo(T)(T t) { return t * n; }
2387 static assert(NS.tupleof.length == 1);
2388 static assert(NS.sizeof == (void*).sizeof);
2389 NS ns;
2390 assert(ns.foo(2) == 20);
2393 /*******************************************/
2394 // 12234
2396 void test12234()
2398 class B
2400 int a;
2401 this(int aa) { a = aa; }
2403 auto foo = {
2404 return new B(1);
2406 static assert(is(typeof(foo) == delegate));
2408 auto b = foo();
2409 assert(b.a == 1);
2412 /*******************************************/
2413 // 12981
2415 template Mix12981(T)
2417 class A
2419 alias typeof(this.outer) x;
2423 class B12981
2425 mixin Mix12981!(int);
2427 static assert(is(A.x == B12981));
2430 /*******************************************/
2431 // 13861
2433 struct Foo13861(alias f)
2435 struct Bar
2437 Bar func()
2439 return Bar(); // OK <- Segfault
2444 void test13861()
2446 Foo13861!(n => n) a;
2449 /*******************************************/
2450 // 14398
2452 void test14398()
2454 int outer;
2456 struct Inner
2458 this(this)
2460 outer += 42;
2464 struct Outer
2466 Inner inner;
2468 this(int dummy)
2470 inner = Inner();
2472 // hidden fields correctly set
2473 assert(this.tupleof[$-1] !is null);
2474 assert(inner.tupleof[$-1] !is null);
2478 Outer[1] arr1 = [Outer(0)];
2479 assert(outer == 0); // no postblit called on arr1 construction
2480 auto arr2 = arr1;
2481 assert(outer == 42); // inner is copied successfully
2484 /*******************************************/
2485 // 14846
2487 void foo14846(Dg)(scope Dg code)
2489 static assert(is(Dg == delegate));
2490 code();
2493 void test14846()
2495 int x;
2497 struct S
2499 this(int n) { x = n; }
2500 ~this() { x = 99; }
2503 foo14846({ S s; });
2504 foo14846({ S s = S(); });
2505 foo14846({ S s = S(1); });
2506 foo14846({ S[3] s; });
2508 foo14846({ S* p = new S(); });
2509 foo14846({ S* p = new S(1); });
2510 foo14846({ S[] a = [S()]; });
2511 foo14846({ S[] a = [S(1)]; });
2514 /*******************************************/
2515 // 15422
2517 class App15422(T)
2519 this() {}
2521 auto test1(T val)
2522 in {} body // necessary to reproduce the crash
2524 struct Foo
2526 this(int k) {}
2527 T a;
2530 Foo foo;
2531 foo.a = val;
2533 // Frame of test2 function, allocated on heap.
2534 assert(foo.tupleof[$-1] !is null);
2536 //printf("&foo = %p\n", &foo); // stack
2537 //printf("&this = %p\n", &this); // stack?
2538 //printf("foo.vthis = %p\n", foo.tupleof[$-1]); // stack...!?
2539 //assert(cast(void*)&this !is *cast(void**)&foo.tupleof[$-1], "bad");
2540 // BUG: currently foo.vthis set to the address of 'this' variable on the stack.
2541 // It's should be stomped to null, because Foo.vthis is never be used.
2543 int[Foo] map;
2544 map[foo] = 1; // OK <- crash
2546 return foo;
2549 auto test2(T val)
2550 //in {} body
2552 int closVar;
2553 struct Foo
2555 this(int k) { closVar = k; }
2556 // Make val a closure variable.
2558 T a;
2561 Foo foo;
2562 foo.a = val;
2564 // Frame of test2 function, allocated on heap.
2565 assert(foo.tupleof[$-1] !is null);
2567 return foo;
2571 void test15422a()
2573 alias App = App15422!int;
2574 App app1 = new App;
2576 auto x = app1.test1(1);
2577 auto y = app1.test1(1);
2578 static assert(is(typeof(x) == typeof(y)));
2580 // int (bitwise comparison)
2581 assert(x.a == y.a);
2583 assert(*cast(void**)&x.tupleof[$-1] is *cast(void**)&y.tupleof[$-1]);
2585 // bitwise equality (needOpEquals() and needToHash() returns false)
2586 assert(x == y);
2588 // BUG
2589 //assert(*cast(void**)&x.tupleof[$-1] is null);
2590 //assert(*cast(void**)&y.tupleof[$-1] is null);
2591 auto getZ() { auto z = app1.test1(1); return z; }
2592 auto z = getZ();
2593 assert(x.a == z.a);
2594 //assert(x.tupleof[$-1] is z.tupleof[$-1]); // should pass
2595 //assert(x == z); // should pass
2597 x = y; // OK, x.tupleof[$-1] = y.tupleof[$-1] is a blit copy.
2599 App app2 = new App;
2601 auto x = app1.test2(1);
2602 auto y = app2.test2(1);
2603 static assert(is(typeof(x) == typeof(y)));
2605 // int (bitwise comparison)
2606 assert(x.a == y.a);
2608 // closure envirionments
2609 assert(*cast(void**)&x.tupleof[$-1] !is *cast(void**)&y.tupleof[$-1]);
2611 // Changed to bitwise equality (needOpEquals() and needToHash() returns false)
2612 assert(x != y); // OK <- crash
2614 x = y; // OK, x.tupleof[$-1] = y.tupleof[$-1] is a blit copy.
2618 void test15422b()
2620 alias App = App15422!string;
2621 App app1 = new App;
2623 auto x = app1.test1("a".idup);
2624 auto y = app1.test1("a".idup);
2625 static assert(is(typeof(x) == typeof(y)));
2627 // string (element-wise comparison)
2628 assert(x.a == y.a);
2630 assert(*cast(void**)&x.tupleof[$-1] is *cast(void**)&y.tupleof[$-1]);
2632 // memberwise equality (needToHash() returns true)
2633 assert(x == y);
2634 // Lowered to: x.a == y.a && x.tupleof[$-1] is y.tupleof[$-1]
2636 // BUG
2637 //assert(*cast(void**)&x.tupleof[$-1] is null);
2638 //assert(*cast(void**)&y.tupleof[$-1] is null);
2639 auto getZ() { auto z = app1.test1("a".idup); return z; }
2640 auto z = getZ();
2641 assert(x.a == z.a);
2642 //assert(x.tupleof[$-1] is z.tupleof[$-1]); // should pass
2643 //assert(x == z); // should pass
2645 x = y; // OK, x.tupleof[$-1] = y.tupleof[$-1] is a blit copy.
2647 App app2 = new App;
2649 auto x = app1.test2("a".idup);
2650 auto y = app2.test2("a".idup);
2651 static assert(is(typeof(x) == typeof(y)));
2653 // string (element-wise comparison)
2654 assert(x.a == y.a);
2656 // closure envirionments
2657 assert(*cast(void**)&x.tupleof[$-1] !is *cast(void**)&y.tupleof[$-1]);
2659 // Changed to memberwise equality (needToHash() returns true)
2660 // Lowered to: x.a == y.a && x.tupleof[$-1] is y.tupleof[$-1]
2661 assert(x != y); // OK <- crash
2663 x = y; // OK, x.tupleof[$-1] = y.tupleof[$-1] is a blit copy.
2667 /***************************************************/
2668 // 15757
2670 template map15757(fun...)
2672 auto map15757(R)(R r)
2674 return MapResult15757!(fun, R)(r);
2678 struct MapResult15757(alias fun, R)
2680 R _input;
2682 this(R input)
2684 _input = input;
2688 void wrap15757(R)(R r)
2690 struct M(R)
2692 this(R r)
2694 payload = r;
2696 R payload;
2699 M!R m = M!R(r);
2702 void test15757() @safe
2704 [1,2,3].map15757!(x => x*x).wrap15757;
2707 /***************************************************/
2709 int main()
2711 test1();
2712 test2();
2713 test3();
2714 test4();
2715 test5();
2716 test6();
2717 test7();
2718 test8();
2719 test9();
2720 test10();
2721 test11();
2722 test12();
2723 test13();
2724 test14();
2725 test15();
2726 test16();
2727 test17();
2728 test18();
2729 test19();
2730 test20();
2731 test21();
2732 test22();
2733 test23();
2734 test24();
2735 test25();
2736 test26();
2737 test27();
2738 test28();
2739 test29();
2740 test30();
2741 test31();
2742 test32();
2743 test33();
2744 test34();
2745 test35();
2746 test36();
2747 test37();
2748 test38();
2749 test39();
2750 test40();
2751 test41();
2752 test42();
2753 test43();
2754 test44();
2755 test45();
2756 test46();
2757 test47();
2758 test48();
2759 test49();
2760 test50();
2761 test51();
2762 test52();
2763 test53();
2764 test54();
2765 test55();
2766 test4401();
2767 test7428();
2768 test4612();
2769 test4841();
2770 test7199();
2771 test7965();
2772 test7965a();
2773 test8188();
2775 test5082();
2776 test8194();
2777 test8339a();
2778 test8339b();
2779 test8339c();
2780 test8923a();
2781 test8923b();
2782 test8923c();
2783 test9003();
2784 test9006();
2785 test9035();
2786 test9035a();
2787 test9036();
2788 // test8863();
2789 test8774();
2790 test8832();
2791 test9315();
2792 test9244();
2793 test11385();
2794 test11297();
2795 test11886();
2796 test12234();
2797 test13861();
2798 test14398();
2799 test14846();
2800 test15422a();
2801 test15422b();
2802 test15757();
2804 printf("Success\n");
2805 return 0;