9 Foo1 foo1_2 = Foo1(); // literal syntax
11 static assert(!__traits(compiles, foo1()));
14 /**************************************/
24 Foo2 foo2_2 = Foo2(1); // user ctor call
25 Foo2 foo2_3 = Foo2(); // literal syntax
27 static assert(!__traits(compiles, foo2(1)));
28 static assert(!__traits(compiles, foo2()));
31 /**************************************/
35 static struct Foo2a // alternation of Foo2
37 static Foo2a opCall(int n){ Foo2a foo2a; return foo2a; }
41 Foo2a foo2a_3 = Foo2a(1); // static opCall
42 static assert(!__traits(compiles, Foo2a())); // static opCall hides literal syntax.
44 foo2a(1); // static opCall from instance
45 static assert(!__traits(compiles, foo2a()));
48 /**************************************/
52 static struct Foo2c // conflict version
55 static Foo2c opCall(int n, int m){ Foo2c foo2c; return foo2c; }
59 Foo2c foo2c_2 = Foo2c(1); // user ctor call
60 static assert(!__traits(compiles, Foo2c(1,2))); // user ctor hides static opCall.
61 Foo2c foo2c_3 = Foo2c(); // literal syntax
63 static assert(!__traits(compiles, foo2c(1)));
64 foo2c(1,2); // static opCall from instance
65 static assert(!__traits(compiles, foo2c()));
68 /**************************************/
75 int opCall(int n){ return 0; }
79 Foo3 foo3_2 = Foo3(); // literal syntax (default construction)
80 Foo3 foo3_3 = Foo3(1); // user ctor call
82 assert(foo3(1) == 0); // instance opCall
83 static assert(!__traits(compiles, foo3()));
86 /**************************************/
93 static Foo3c opCall(int n, int m){ Foo3c foo3c; return foo3c; }
94 int opCall(int n){ return 0; }
98 Foo3c foo3c_2 = Foo3c(); // literal syntax (default construction)
99 Foo3c foo3c_3 = Foo3c(1); // user ctor call
100 static assert(!__traits(compiles, Foo3c(1,2))); // user ctor hides static opCall
102 assert(foo3c(1,2) == Foo3c.init); // static opCall from instance
103 assert(foo3c(1) == 0); // instance opCall
104 static assert(!__traits(compiles, foo3c()));
107 /**************************************/
113 static Foo4 opCall(int n, int m){ Foo4 foo4; return foo4; }
114 int opCall(int n){ return 0; }
118 Foo4 foo4_4 = Foo4(1,2); // static opCall
119 static assert(!__traits(compiles, Foo4(1)));
120 static assert(!__traits(compiles, Foo4())); // static opCall without constructor hides literal syntax
122 assert(foo4(1,2) == Foo4.init); // static opCall from instance
123 assert(foo4(1) == 0); // instance opCall
124 static assert(!__traits(compiles, foo4()));
127 /**************************************/
128 // https://issues.dlang.org/show_bug.cgi?id=12070
132 static string result;
138 result ~= "c" ~ cast(char)('0' + T.length);
143 result ~= "x" ~ cast(char)('0' + A.length);
151 assert(result == "x0x1x2");
159 assert(result == "c1x0x1x2");
162 /**************************************/
163 // https://issues.dlang.org/show_bug.cgi?id=12124
168 S12124 opCall()() { static assert(0); }
169 // speculative opCall instantiation for diagnostic message should not cause false errors
172 /**************************************/