1 // COMPILABLE_MATH_TEST
3 // EXTRA_FILES: imports/a12506.d
6 compilable/compile1.d(229): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
10 /***************************************************/
11 // https://issues.dlang.org/show_bug.cgi?id=1748
12 // class template with stringof
15 static assert(S1748!int.stringof == "S1748!int");
18 static assert(C1748!int.stringof == "C1748!int");
20 /***************************************************/
21 // https://issues.dlang.org/show_bug.cgi?id=2354
22 // pragma + single semicolon DeclarationBlock
27 pragma(inline, false);
29 /***************************************************/
30 // https://issues.dlang.org/show_bug.cgi?id=2438
32 alias void delegate() Dg2438;
34 alias typeof(Dg2438.ptr) CP2438a;
35 alias typeof(Dg2438.funcptr) FP2438a;
36 static assert(is(CP2438a == void*));
37 static assert(is(FP2438a == void function()));
39 alias typeof(Dg2438.init.ptr) CP2438b;
40 alias typeof(Dg2438.init.funcptr) FP2438b;
41 static assert(is(CP2438b == void*));
42 static assert(is(FP2438b == void function()));
44 /***************************************************/
45 // https://issues.dlang.org/show_bug.cgi?id=4225
51 static Foo4225 opCall()
57 /***************************************************/
58 // https://issues.dlang.org/show_bug.cgi?id=5996
68 static assert(!is(typeof(T5996!(int).bug5996())));
70 /***************************************************/
71 // https://issues.dlang.org/show_bug.cgi?id=8532
72 // segfault(mtype.c) - type inference + pure
74 auto segfault8532(Y, R ...)(R r, Y val) pure
75 { return segfault8532(r, val); }
77 static assert(!is(typeof( segfault8532(1,2,3))));
79 /***************************************************/
80 // https://issues.dlang.org/show_bug.cgi?id=8982
81 // ICE(ctfeexpr.c) __parameters with error in default value
85 void bug8982(ref const int v = 7){}
87 static if (is(typeof(bug8982) P == __parameters)) {
88 enum eval8982 = ((P[0..1] g) => g[0])();
92 static assert(!is(ice8982!(int)));
95 /***************************************************/
96 // https://issues.dlang.org/show_bug.cgi?id=8801
97 // ICE assigning to __ctfe
99 static assert(!is(typeof( { bool __ctfe= true; })));
100 static assert(!is(typeof( { __ctfe |= true; })));
102 /***************************************************/
103 // https://issues.dlang.org/show_bug.cgi?id=5932
104 // https://issues.dlang.org/show_bug.cgi?id=6675
105 // ICE(s2ir.c), ICE(glue.c)
112 void func5932(T)( T val ) {
113 void onStandardMsg() {
118 static assert(!is(typeof(
124 /***************************************************/
125 // https://issues.dlang.org/show_bug.cgi?id=6650
126 // ICE(glue.c) or wrong-code
135 static assert(!is(typeof(bug6650!(int)(6))));
136 static assert(!is(typeof(bug6650!(int)(18))));
138 /***************************************************/
139 // https://issues.dlang.org/show_bug.cgi?id=14710
140 // VC-built DMD crashes on templated variadic function IFTI
142 void bug14710a(T)(T val, T[] arr...)
151 /***************************************************/
152 // https://issues.dlang.org/show_bug.cgi?id=6661
153 // Templates instantiated only through is(typeof()) shouldn't cause errors
162 static assert(qutz(13).sizeof!=299);
166 static assert(!is(typeof(bug6661!(int).blaz)));
176 // should pass, but doesn't in current
177 //static assert(!is(typeof(bug6661x!(int))));
179 /***************************************************/
180 // https://issues.dlang.org/show_bug.cgi?id=6599
181 // ICE(constfold.c) or segfault
183 string bug6599extraTest(string x) { return x ~ "abc"; }
189 Repository repository = Repository();
194 string fileProtocol = "file://";
195 string blah = bug6599extraTest("abc");
196 string source = fileProtocol ~ "/usr/local/orbit/repository";
200 static assert(!is(typeof(Bug6599!int)));
202 /***************************************************/
203 // https://issues.dlang.org/show_bug.cgi?id=8422
204 // TypeTuple of tuples can't be read at compile time
206 template TypeTuple8422(TList...)
208 alias TList TypeTuple8422;
211 struct S8422 { int x; }
218 foreach(t; TypeTuple8422!(b, a)) {
221 foreach(t; TypeTuple8422!(c)) {
226 /***************************************************/
227 // https://issues.dlang.org/show_bug.cgi?id=6096
238 /***************************************************/
239 // https://issues.dlang.org/show_bug.cgi?id=7681
242 static assert( !is(typeof( (){
243 undefined ~= delegate(){}; return 7;
246 /***************************************************/
247 // https://issues.dlang.org/show_bug.cgi?id=8639
250 void t8639(alias a)() {}
252 t8639!({auto r = -real.max;})();
255 /***************************************************/
256 // https://issues.dlang.org/show_bug.cgi?id=7751
259 static assert( !is(typeof( (){
264 /***************************************************/
265 // https://issues.dlang.org/show_bug.cgi?id=7639
268 static assert( !is(typeof( (){
275 /***************************************************/
276 // https://issues.dlang.org/show_bug.cgi?id=11991
285 catch(.object.Throwable)
290 /***************************************************/
291 // https://issues.dlang.org/show_bug.cgi?id=11939
297 import object : Object;
299 throw new Exception("");
302 /***************************************************/
303 // https://issues.dlang.org/show_bug.cgi?id=5796
306 pragma(lib, "missing ;")
310 static assert(!is(typeof(A!(int))));
312 /***************************************************/
313 // https://issues.dlang.org/show_bug.cgi?id=6720
317 static assert(!is(typeof(
321 /***************************************************/
322 // https://issues.dlang.org/show_bug.cgi?id=1099
324 template Mix1099(int a) {
325 alias typeof(this) ThisType;
326 static assert (ThisType.init.tupleof.length == 2);
338 /***************************************************/
339 // https://issues.dlang.org/show_bug.cgi?id=8788
340 // super() and return
346 class C8788(int test) : B8788
349 { // TESTS WHICH SHOULD PASS
350 static if (test == 1) {
357 } else static if (test == 2) {
363 } else static if (test == 3) {
373 } else static if (test == 4) {
386 // TESTS WHICH SHOULD FAIL
387 else static if (test == 5) {
393 } else static if (test == 6) {
401 super(); // two calls
402 } else static if (test == 7) {
407 } else static if (test == 8) {
416 } else static if (test == 9) {
424 else return; // no super
432 static assert( is(typeof( { new C8788!(1)(0); } )));
433 static assert( is(typeof( { new C8788!(2)(0); } )));
434 static assert( is(typeof( { new C8788!(3)(0); } )));
435 static assert( is(typeof( { new C8788!(4)(0); } )));
436 static assert(!is(typeof( { new C8788!(5)(0); } )));
437 static assert(!is(typeof( { new C8788!(6)(0); } )));
438 static assert(!is(typeof( { new C8788!(7)(0); } )));
439 static assert(!is(typeof( { new C8788!(8)(0); } )));
440 static assert(!is(typeof( { new C8788!(9)(0); } )));
442 /***************************************************/
443 // https://issues.dlang.org/show_bug.cgi?id=4967
444 // https://issues.dlang.org/show_bug.cgi?id=7058
446 enum Bug7058 bug7058 = { 1.5f, 2};
447 static assert(bug7058.z == 99);
457 /***************************************************/
465 auto u = true ? null : a;
466 auto v = true ? null : b;
467 auto w = true ? null : c;
468 auto x = true ? n : a;
469 auto y = true ? n : b;
470 auto z = true ? n : c;
476 /***************************************************/
478 template test8163(T...)
485 enum N = 2; // N>=2 triggers the bug
486 extern Point[N] bar();
494 alias test8163!(long) _l;
495 alias test8163!(double) _d;
496 alias test8163!(float, float) _ff;
497 alias test8163!(int, int) _ii;
498 alias test8163!(int, float) _if;
499 alias test8163!(ushort, ushort, ushort, ushort) _SSSS;
500 alias test8163!(ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte) _BBBBBBBB;
501 alias test8163!(ubyte, ubyte, ushort, float) _BBSf;
504 /***************************************************/
505 // https://issues.dlang.org/show_bug.cgi?id=4757
524 /***************************************************/
525 // https://issues.dlang.org/show_bug.cgi?id=9348
529 @property Object F(int E)() { return null; }
531 assert(F!0 !is null);
532 assert(F!0 !in [new Object():1]);
535 /***************************************************/
536 // https://issues.dlang.org/show_bug.cgi?id=9690
546 dep9690(); // OK <- NG
551 /***************************************************/
552 // https://issues.dlang.org/show_bug.cgi?id=9987
554 static if (is(object.ModuleInfo == struct))
558 static assert(!is(object.ModuleInfo == ModuleInfo));
559 static assert(object.ModuleInfo.sizeof != ModuleInfo.sizeof);
561 static if (is(object.ModuleInfo == class))
565 static assert(!is(object.ModuleInfo == ModuleInfo));
566 static assert(__traits(classInstanceSize, object.ModuleInfo) !=
567 __traits(classInstanceSize, ModuleInfo));
570 /***************************************************/
571 // https://issues.dlang.org/show_bug.cgi?id=10158
582 static assert( Inner.f .offsetof == 0); // OK <- NG
583 static assert((Inner.f).offsetof == 0); // OK
589 static assert(Outer10158.Inner.f.offsetof == 0); // OK
592 /***************************************************/
593 // https://issues.dlang.org/show_bug.cgi?id=10326
598 invariant { assert(val == 0); }
599 invariant() { assert(val == 0); }
602 /***************************************************/
603 // https://issues.dlang.org/show_bug.cgi?id=11042
605 static if ((true || error) == true ) {} else { static assert(0); }
606 static if ((false && error) == false) {} else { static assert(0); }
607 static assert ((true || error) == true );
608 static assert ((false && error) == false);
609 int f11042a1()() if ((true || error) == true ) { return 0; } enum x11042a1 = f11042a1();
610 int f11042b1()() if ((false && error) == false) { return 0; } enum x11042b1 = f11042b1();
612 static if (is(typeof(true || error)) == false) {} else { static assert(0); }
613 static if (is(typeof(false && error)) == false) {} else { static assert(0); }
614 static assert (is(typeof(true || error)) == false);
615 static assert (is(typeof(false && error)) == false);
616 int f11042a2()() if (is(typeof(true || error)) == false) { return 0; } enum x11042a2 = f11042a2();
617 int f11042b2()() if (is(typeof(false && error)) == false) { return 0; } enum x11042b2 = f11042b2();
619 static if (__traits(compiles, true || error) == false) {} else { static assert(0); }
620 static if (__traits(compiles, false && error) == false) {} else { static assert(0); }
621 static assert (__traits(compiles, true || error) == false);
622 static assert (__traits(compiles, false && error) == false);
623 int f11042a3()() if (__traits(compiles, true || error) == false) { return 0; } enum x11042a3 = f11042a3();
624 int f11042b3()() if (__traits(compiles, false && error) == false) { return 0; } enum x11042b3 = f11042b3();
626 /***************************************************/
627 // https://issues.dlang.org/show_bug.cgi?id=11554
630 static assert(is(E11554 == enum));
632 struct Bro11554(N...) {}
633 static assert(!is(E11554 unused : Bro11554!M, M...));
635 /***************************************************/
636 // https://issues.dlang.org/show_bug.cgi?id=12302
638 template isCallable12302(T...)
641 static if (is(typeof(& T[0].opCall) == delegate))
642 enum bool isCallable12302 = true;
644 static if (is(typeof(& T[0].opCall) V : V*) && is(V == function))
645 enum bool isCallable12302 = true;
647 enum bool isCallable12302 = true;
654 auto opDispatch(string s, TArgs...)(TArgs args)
656 mixin("return x."~s~"(args);");
660 A12302 func12302() { return null; }
661 enum b12302 = isCallable12302!func12302;
663 /***************************************************/
664 // https://issues.dlang.org/show_bug.cgi?id=12476
666 template A12476(T) { }
678 struct Bar12476(alias Foo)
684 alias Identity12476(alias A) = A;
686 alias sb12476 = Identity12476!(Bar12476!S12476.B);
687 alias cb12476 = Identity12476!(Bar12476!C12476.B);
689 static assert(__traits(isSame, sb12476, A12476!int));
690 static assert(__traits(isSame, cb12476, A12476!int));
692 /***************************************************/
693 // https://issues.dlang.org/show_bug.cgi?id=12506
695 import imports.a12506;
696 private bool[9] r12506a = f12506!(i => true)(); // OK
697 private immutable bool[9] r12506b = f12506!(i => true)(); // OK <- error
699 /***************************************************/
700 // https://issues.dlang.org/show_bug.cgi?id=12555
707 static assert(!__traits(compiles, {
708 class C : A12555!C { }
711 /***************************************************/
712 // https://issues.dlang.org/show_bug.cgi?id=11622
726 static assert(!__traits(compiles, {
727 class C : A11622!C { }
730 /***************************************************/
731 // https://issues.dlang.org/show_bug.cgi?id=12688
733 void writeln12688(A...)(A) {}
737 int foo() @property { return 1; }
743 s.foo.writeln12688; // ok
744 (s.foo).writeln12688; // ok <- ng
747 /***************************************************/
748 // https://issues.dlang.org/show_bug.cgi?id=12703
757 S12703 s = S12703(1);
760 /***************************************************/
761 // https://issues.dlang.org/show_bug.cgi?id=12799
766 enum C = A12799.sizeof;
767 enum D = C; // OK <- Error
770 /***************************************************/
771 // https://issues.dlang.org/show_bug.cgi?id=13236
773 enum bug13286 = is(typeof({ struct S { S x; } }));
775 /***************************************************/
776 // https://issues.dlang.org/show_bug.cgi?id=13280
781 alias T1 = ubyte[this.sizeof]; // ok
782 alias T2 = const U[this.sizeof]; // ok
783 alias T3 = const ubyte[this.sizeof]; // ok <- error
786 /***************************************************/
787 // https://issues.dlang.org/show_bug.cgi?id=13481
789 mixin template Mix13481(void function() callback)
797 /***************************************************/
798 // https://issues.dlang.org/show_bug.cgi?id=13564
821 auto c = new C13564!int();
824 /***************************************************/
825 // https://issues.dlang.org/show_bug.cgi?id=14166
830 ref deref() { return *ptr; }
835 auto opIndex() { return this; }
836 auto opIndex(int) { return 1; }
838 template Elem14166a(R) { alias Elem14166a = typeof(R.init[][0]); }
839 template Elem14166b(R) { alias Elem14166b = typeof(R.init[0]); }
842 alias T = Proxy14166!Test14166;
843 static assert(is(Elem14166a!T == int)); // rejects-valid case
844 static assert(is(Elem14166b!T == int)); // regression case
847 // other related cases
853 S14166 opUnary(string op : "++")() { return this; }
857 struct X14166 { this(int) { } X14166 opAssign(int) { return this; } }
859 X14166[int] makeAA14166() { return aa14166; }
861 struct Tup14166(T...) { T field; alias field this; }
862 Tup14166!(int, int) tup14166;
863 Tup14166!(int, int) makeTup14166() { return tup14166; }
864 alias TT14166(T...) = T;
866 static assert(is(typeof((s14166.x += 1) = 2) == int)); // ok <- error
867 static assert(is(typeof(s14166.a.length += 2) == size_t)); // ok <- error
868 static assert(is(typeof(s14166++) == S14166)); // ok <- error
869 static assert(is(typeof(s14166.x ^^ 2) == int)); // ok <- error
870 static assert(is(typeof(s14166.y ^^= 2.5) == double)); // ok <- error
871 static assert(is(typeof(makeAA14166()[0] = 1) == X14166)); // ok <- error
872 static assert(is(typeof(tup14166.field = makeTup14166()) == TT14166!(int, int))); // ok <- error
874 /***************************************************/
875 // https://issues.dlang.org/show_bug.cgi?id=14388
877 @property immutable(T)[] idup14388(T)(T[] a)
879 alias U = immutable(T);
886 struct Data14388(A14388 a)
890 return Data14388!a.init; // [B]
898 immutable(Item)[] items;
902 items = [Item()].idup14388;
908 auto test = Data14388!(A14388(42)).init.foo(); // [A]
910 * A(42) is interpreter to a struct literal A([immutable(Item)()]).
911 * The internal VarDeclaration with STCmanifest for the Data's template parameteter 'a'
912 * calls syntaxCopy() on its ((ExpInitializer *)init)->exp in VarDeclaration::semantic(),
913 * and 'immutable(Item)()'->syntaxCopy() had incorrectly removed the qualifier.
914 * Then, the arguments of two Data template instances at [A] and [B] had become unmatch,
915 * and the second instantiation had created the AST duplication.
919 /***************************************************/
920 // https://issues.dlang.org/show_bug.cgi?id=15163
922 void function() func15164(int[] arr)
933 /***************************************************/
934 // https://issues.dlang.org/show_bug.cgi?id=3438
937 struct S3438_1 { this(int x, int y = 1) { } }
938 struct S3438_2 { this(int x, ...) { } }
939 struct S3438_3 { this(int x, int[] arr...) { } }
940 struct S3438_4 { this(...) { } }
941 struct S3438_5 { this(int[] arr...) { } }
943 /***************************************************/
944 // https://issues.dlang.org/show_bug.cgi?id=15362
950 assert(true, "So true");
951 assert(true, "Very, very true",);
953 static assert(true,);
954 static assert(true, "So true");
955 static assert(true, "Very, very true",);
958 /***************************************************/
959 // https://issues.dlang.org/show_bug.cgi?id=15799
968 }; // Semicolon is not a part of function declaration. It's an empty declaration.
971 /***************************************************/
972 // https://issues.dlang.org/show_bug.cgi?id=21163
976 void function(scope int) fp;
983 /***************************************************/
984 // https://issues.dlang.org/show_bug.cgi?id=11624
991 static assert(!__traits(compiles,
993 static class C11624 : I11624 { }