| 1 |
// COMPILABLE_MATH_TEST |
| 2 |
// PERMUTE_ARGS: |
| 3 |
// REQUIRED_ARGS: -verrors=simple |
| 4 |
// EXTRA_FILES: imports/a12506.d |
| 5 |
/* TEST_OUTPUT: |
| 6 |
--- |
| 7 |
compilable/compile1.d(231): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead |
| 8 |
--- |
| 9 |
*/ |
| 10 |
|
| 11 |
/***************************************************/ |
| 12 |
// https://issues.dlang.org/show_bug.cgi?id=1748 |
| 13 |
// class template with stringof |
| 14 |
|
| 15 |
struct S1748(T) {} |
| 16 |
static assert(S1748!int.stringof == "S1748!int"); |
| 17 |
|
| 18 |
class C1748(T) {} |
| 19 |
static assert(C1748!int.stringof == "C1748!int"); |
| 20 |
|
| 21 |
/***************************************************/ |
| 22 |
// https://issues.dlang.org/show_bug.cgi?id=2354 |
| 23 |
// pragma + single semicolon DeclarationBlock |
| 24 |
|
| 25 |
version(all) |
| 26 |
pragma(inline, true); |
| 27 |
else |
| 28 |
pragma(inline, false); |
| 29 |
|
| 30 |
/***************************************************/ |
| 31 |
// https://issues.dlang.org/show_bug.cgi?id=2438 |
| 32 |
|
| 33 |
alias void delegate() Dg2438; |
| 34 |
|
| 35 |
alias typeof(Dg2438.ptr) CP2438a; |
| 36 |
alias typeof(Dg2438.funcptr) FP2438a; |
| 37 |
static assert(is(CP2438a == void*)); |
| 38 |
static assert(is(FP2438a == void function())); |
| 39 |
|
| 40 |
alias typeof(Dg2438.init.ptr) CP2438b; |
| 41 |
alias typeof(Dg2438.init.funcptr) FP2438b; |
| 42 |
static assert(is(CP2438b == void*)); |
| 43 |
static assert(is(FP2438b == void function())); |
| 44 |
|
| 45 |
/***************************************************/ |
| 46 |
// https://issues.dlang.org/show_bug.cgi?id=4225 |
| 47 |
|
| 48 |
struct Foo4225 |
| 49 |
{ |
| 50 |
enum x = Foo4225(); |
| 51 |
|
| 52 |
static Foo4225 opCall() |
| 53 |
{ |
| 54 |
return Foo4225.init; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
/***************************************************/ |
| 59 |
// https://issues.dlang.org/show_bug.cgi?id=5996 |
| 60 |
// ICE(expression.c) |
| 61 |
|
| 62 |
template T5996(T) |
| 63 |
{ |
| 64 |
auto bug5996() { |
| 65 |
if (anyOldGarbage) {} |
| 66 |
return 2; |
| 67 |
} |
| 68 |
} |
| 69 |
static assert(!is(typeof(T5996!(int).bug5996()))); |
| 70 |
|
| 71 |
/***************************************************/ |
| 72 |
// https://issues.dlang.org/show_bug.cgi?id=8532 |
| 73 |
// segfault(mtype.c) - type inference + pure |
| 74 |
|
| 75 |
auto segfault8532(Y, R ...)(R r, Y val) pure |
| 76 |
{ return segfault8532(r, val); } |
| 77 |
|
| 78 |
static assert(!is(typeof( segfault8532(1,2,3)))); |
| 79 |
|
| 80 |
/***************************************************/ |
| 81 |
// https://issues.dlang.org/show_bug.cgi?id=8982 |
| 82 |
// ICE(ctfeexpr.c) __parameters with error in default value |
| 83 |
|
| 84 |
template ice8982(T) |
| 85 |
{ |
| 86 |
void bug8982(ref const int v = 7){} |
| 87 |
|
| 88 |
static if (is(typeof(bug8982) P == __parameters)) { |
| 89 |
enum eval8982 = ((P[0..1] g) => g[0])(); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
static assert(!is(ice8982!(int))); |
| 94 |
|
| 95 |
|
| 96 |
/***************************************************/ |
| 97 |
// https://issues.dlang.org/show_bug.cgi?id=8801 |
| 98 |
// ICE assigning to __ctfe |
| 99 |
|
| 100 |
static assert(!is(typeof( { bool __ctfe= true; }))); |
| 101 |
static assert(!is(typeof( { __ctfe |= true; }))); |
| 102 |
|
| 103 |
/***************************************************/ |
| 104 |
// https://issues.dlang.org/show_bug.cgi?id=5932 |
| 105 |
// https://issues.dlang.org/show_bug.cgi?id=6675 |
| 106 |
// ICE(s2ir.c), ICE(glue.c) |
| 107 |
|
| 108 |
void bug3932(T)() { |
| 109 |
static assert( 0 ); |
| 110 |
func5932( 7 ); |
| 111 |
} |
| 112 |
|
| 113 |
void func5932(T)( T val ) { |
| 114 |
void onStandardMsg() { |
| 115 |
foreach( t; T ) { } |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
static assert(!is(typeof( |
| 120 |
{ |
| 121 |
bug3932!(int)(); |
| 122 |
}() |
| 123 |
))); |
| 124 |
|
| 125 |
/***************************************************/ |
| 126 |
// https://issues.dlang.org/show_bug.cgi?id=6650 |
| 127 |
// ICE(glue.c) or wrong-code |
| 128 |
|
| 129 |
auto bug6650(X)(X y) |
| 130 |
{ |
| 131 |
X q; |
| 132 |
q = "abc"; |
| 133 |
return y; |
| 134 |
} |
| 135 |
|
| 136 |
static assert(!is(typeof(bug6650!(int)(6)))); |
| 137 |
static assert(!is(typeof(bug6650!(int)(18)))); |
| 138 |
|
| 139 |
/***************************************************/ |
| 140 |
// https://issues.dlang.org/show_bug.cgi?id=14710 |
| 141 |
// VC-built DMD crashes on templated variadic function IFTI |
| 142 |
|
| 143 |
void bug14710a(T)(T val, T[] arr...) |
| 144 |
{ |
| 145 |
} |
| 146 |
|
| 147 |
void bug14710b() |
| 148 |
{ |
| 149 |
bug14710a("", ""); |
| 150 |
} |
| 151 |
|
| 152 |
/***************************************************/ |
| 153 |
// https://issues.dlang.org/show_bug.cgi?id=6661 |
| 154 |
// Templates instantiated only through is(typeof()) shouldn't cause errors |
| 155 |
|
| 156 |
template bug6661(Q) |
| 157 |
{ |
| 158 |
int qutz(Q y) |
| 159 |
{ |
| 160 |
Q q = "abc"; |
| 161 |
return 67; |
| 162 |
} |
| 163 |
static assert(qutz(13).sizeof!=299); |
| 164 |
const Q blaz = 6; |
| 165 |
} |
| 166 |
|
| 167 |
static assert(!is(typeof(bug6661!(int).blaz))); |
| 168 |
|
| 169 |
template bug6661x(Q) |
| 170 |
{ |
| 171 |
int qutz(Q y) |
| 172 |
{ |
| 173 |
Q q = "abc"; |
| 174 |
return 67; |
| 175 |
} |
| 176 |
} |
| 177 |
// should pass, but doesn't in current |
| 178 |
//static assert(!is(typeof(bug6661x!(int)))); |
| 179 |
|
| 180 |
/***************************************************/ |
| 181 |
// https://issues.dlang.org/show_bug.cgi?id=6599 |
| 182 |
// ICE(constfold.c) or segfault |
| 183 |
|
| 184 |
string bug6599extraTest(string x) { return x ~ "abc"; } |
| 185 |
|
| 186 |
template Bug6599(X) |
| 187 |
{ |
| 188 |
class Orbit |
| 189 |
{ |
| 190 |
Repository repository = Repository(); |
| 191 |
} |
| 192 |
|
| 193 |
struct Repository |
| 194 |
{ |
| 195 |
string fileProtocol = "file://"; |
| 196 |
string blah = bug6599extraTest("abc"); |
| 197 |
string source = fileProtocol ~ "/usr/local/orbit/repository"; |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
static assert(!is(typeof(Bug6599!int))); |
| 202 |
|
| 203 |
/***************************************************/ |
| 204 |
// https://issues.dlang.org/show_bug.cgi?id=8422 |
| 205 |
// TypeTuple of tuples can't be read at compile time |
| 206 |
|
| 207 |
template TypeTuple8422(TList...) |
| 208 |
{ |
| 209 |
alias TList TypeTuple8422; |
| 210 |
} |
| 211 |
|
| 212 |
struct S8422 { int x; } |
| 213 |
|
| 214 |
void test8422() |
| 215 |
{ |
| 216 |
enum a = S8422(1); |
| 217 |
enum b = S8422(2); |
| 218 |
enum c = [1,2,3]; |
| 219 |
foreach(t; TypeTuple8422!(b, a)) { |
| 220 |
enum u = t; |
| 221 |
} |
| 222 |
foreach(t; TypeTuple8422!(c)) { |
| 223 |
enum v = t; |
| 224 |
} |
| 225 |
} |
| 226 |
|
| 227 |
/***************************************************/ |
| 228 |
// https://issues.dlang.org/show_bug.cgi?id=6096 |
| 229 |
// ICE(el.c) with -O |
| 230 |
|
| 231 |
cdouble c6096; |
| 232 |
|
| 233 |
int bug6096() |
| 234 |
{ |
| 235 |
if (c6096) return 0; |
| 236 |
return 1; |
| 237 |
} |
| 238 |
|
| 239 |
/***************************************************/ |
| 240 |
// https://issues.dlang.org/show_bug.cgi?id=7681 |
| 241 |
// Segfault |
| 242 |
|
| 243 |
static assert( !is(typeof( (){ |
| 244 |
undefined ~= delegate(){}; return 7; |
| 245 |
}()))); |
| 246 |
|
| 247 |
/***************************************************/ |
| 248 |
// https://issues.dlang.org/show_bug.cgi?id=8639 |
| 249 |
// Buffer overflow |
| 250 |
|
| 251 |
void t8639(alias a)() {} |
| 252 |
void bug8639() { |
| 253 |
t8639!({auto r = -real.max;})(); |
| 254 |
} |
| 255 |
|
| 256 |
/***************************************************/ |
| 257 |
// https://issues.dlang.org/show_bug.cgi?id=7751 |
| 258 |
// Segfault |
| 259 |
|
| 260 |
static assert( !is(typeof( (){ |
| 261 |
bar[]r; r ~= []; |
| 262 |
return 7; |
| 263 |
}()))); |
| 264 |
|
| 265 |
/***************************************************/ |
| 266 |
// https://issues.dlang.org/show_bug.cgi?id=7639 |
| 267 |
// Segfault |
| 268 |
|
| 269 |
static assert( !is(typeof( (){ |
| 270 |
enum foo = |
| 271 |
[ |
| 272 |
str : "functions", |
| 273 |
]; |
| 274 |
}))); |
| 275 |
|
| 276 |
/***************************************************/ |
| 277 |
// https://issues.dlang.org/show_bug.cgi?id=11991 |
| 278 |
|
| 279 |
void main() |
| 280 |
{ |
| 281 |
int Throwable; |
| 282 |
int object; |
| 283 |
try |
| 284 |
{ |
| 285 |
} |
| 286 |
catch(.object.Throwable) |
| 287 |
{ |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
/***************************************************/ |
| 292 |
// https://issues.dlang.org/show_bug.cgi?id=11939 |
| 293 |
|
| 294 |
void test11939() |
| 295 |
{ |
| 296 |
scope(failure) |
| 297 |
{ |
| 298 |
import object : Object; |
| 299 |
} |
| 300 |
throw new Exception(""); |
| 301 |
} |
| 302 |
|
| 303 |
/***************************************************/ |
| 304 |
// https://issues.dlang.org/show_bug.cgi?id=5796 |
| 305 |
|
| 306 |
template A(B) { |
| 307 |
pragma(lib, "missing ;") |
| 308 |
enum X = 0; |
| 309 |
} |
| 310 |
|
| 311 |
static assert(!is(typeof(A!(int)))); |
| 312 |
|
| 313 |
/***************************************************/ |
| 314 |
// https://issues.dlang.org/show_bug.cgi?id=6720 |
| 315 |
|
| 316 |
void bug6720() { } |
| 317 |
|
| 318 |
static assert(!is(typeof( |
| 319 |
cast(bool)bug6720() |
| 320 |
))); |
| 321 |
|
| 322 |
/***************************************************/ |
| 323 |
// https://issues.dlang.org/show_bug.cgi?id=1099 |
| 324 |
|
| 325 |
template Mix1099(int a) { |
| 326 |
alias typeof(this) ThisType; |
| 327 |
static assert (ThisType.init.tupleof.length == 2); |
| 328 |
} |
| 329 |
|
| 330 |
|
| 331 |
struct Foo1099 { |
| 332 |
mixin Mix1099!(0); |
| 333 |
int foo; |
| 334 |
mixin Mix1099!(1); |
| 335 |
int bar; |
| 336 |
mixin Mix1099!(2); |
| 337 |
} |
| 338 |
|
| 339 |
/***************************************************/ |
| 340 |
// https://issues.dlang.org/show_bug.cgi?id=8788 |
| 341 |
// super() and return |
| 342 |
|
| 343 |
class B8788 { |
| 344 |
this ( ) { } |
| 345 |
} |
| 346 |
|
| 347 |
class C8788(int test) : B8788 |
| 348 |
{ |
| 349 |
this ( int y ) |
| 350 |
{ // TESTS WHICH SHOULD PASS |
| 351 |
static if (test == 1) { |
| 352 |
if (y == 3) { |
| 353 |
super(); |
| 354 |
return; |
| 355 |
} |
| 356 |
super(); |
| 357 |
return; |
| 358 |
} else static if (test == 2) { |
| 359 |
if (y == 3) { |
| 360 |
super(); |
| 361 |
return; |
| 362 |
} |
| 363 |
super(); |
| 364 |
} else static if (test == 3) { |
| 365 |
if (y > 3) { |
| 366 |
if (y == 7) { |
| 367 |
super(); |
| 368 |
return; |
| 369 |
} |
| 370 |
super(); |
| 371 |
return; |
| 372 |
} |
| 373 |
super(); |
| 374 |
} else static if (test == 4) { |
| 375 |
if (y > 3) { |
| 376 |
if (y == 7) { |
| 377 |
super(); |
| 378 |
return; |
| 379 |
} |
| 380 |
else if (y> 5) |
| 381 |
super(); |
| 382 |
else super(); |
| 383 |
return; |
| 384 |
} |
| 385 |
super(); |
| 386 |
} |
| 387 |
// TESTS WHICH SHOULD FAIL |
| 388 |
else static if (test == 5) { |
| 389 |
if (y == 3) { |
| 390 |
super(); |
| 391 |
return; |
| 392 |
} |
| 393 |
return; // no super |
| 394 |
} else static if (test == 6) { |
| 395 |
if (y > 3) { |
| 396 |
if (y == 7) { |
| 397 |
super(); |
| 398 |
return; |
| 399 |
} |
| 400 |
super(); |
| 401 |
} |
| 402 |
super(); // two calls |
| 403 |
} else static if (test == 7) { |
| 404 |
if (y == 3) { |
| 405 |
return; // no super |
| 406 |
} |
| 407 |
super(); |
| 408 |
} else static if (test == 8) { |
| 409 |
if (y > 3) { |
| 410 |
if (y == 7) { |
| 411 |
return; // no super |
| 412 |
} |
| 413 |
super(); |
| 414 |
return; |
| 415 |
} |
| 416 |
super(); |
| 417 |
} else static if (test == 9) { |
| 418 |
if (y > 3) { |
| 419 |
if (y == 7) { |
| 420 |
super(); |
| 421 |
return; |
| 422 |
} |
| 423 |
else if (y> 5) |
| 424 |
super(); |
| 425 |
else return; // no super |
| 426 |
return; |
| 427 |
} |
| 428 |
super(); |
| 429 |
} |
| 430 |
} |
| 431 |
} |
| 432 |
|
| 433 |
static assert( is(typeof( { new C8788!(1)(0); } ))); |
| 434 |
static assert( is(typeof( { new C8788!(2)(0); } ))); |
| 435 |
static assert( is(typeof( { new C8788!(3)(0); } ))); |
| 436 |
static assert( is(typeof( { new C8788!(4)(0); } ))); |
| 437 |
static assert(!is(typeof( { new C8788!(5)(0); } ))); |
| 438 |
static assert(!is(typeof( { new C8788!(6)(0); } ))); |
| 439 |
static assert(!is(typeof( { new C8788!(7)(0); } ))); |
| 440 |
static assert(!is(typeof( { new C8788!(8)(0); } ))); |
| 441 |
static assert(!is(typeof( { new C8788!(9)(0); } ))); |
| 442 |
|
| 443 |
/***************************************************/ |
| 444 |
// https://issues.dlang.org/show_bug.cgi?id=4967 |
| 445 |
// https://issues.dlang.org/show_bug.cgi?id=7058 |
| 446 |
|
| 447 |
enum Bug7058 bug7058 = { 1.5f, 2}; |
| 448 |
static assert(bug7058.z == 99); |
| 449 |
|
| 450 |
struct Bug7058 |
| 451 |
{ |
| 452 |
float x = 0; |
| 453 |
float y = 0; |
| 454 |
float z = 99; |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
/***************************************************/ |
| 459 |
|
| 460 |
void test12094() |
| 461 |
{ |
| 462 |
auto n = null; |
| 463 |
int *a; |
| 464 |
int[int] b; |
| 465 |
int[] c; |
| 466 |
auto u = true ? null : a; |
| 467 |
auto v = true ? null : b; |
| 468 |
auto w = true ? null : c; |
| 469 |
auto x = true ? n : a; |
| 470 |
auto y = true ? n : b; |
| 471 |
auto z = true ? n : c; |
| 472 |
a = n; |
| 473 |
b = n; |
| 474 |
c = n; |
| 475 |
} |
| 476 |
|
| 477 |
/***************************************************/ |
| 478 |
|
| 479 |
template test8163(T...) |
| 480 |
{ |
| 481 |
struct Point |
| 482 |
{ |
| 483 |
T fields; |
| 484 |
} |
| 485 |
|
| 486 |
enum N = 2; // N>=2 triggers the bug |
| 487 |
extern Point[N] bar(); |
| 488 |
|
| 489 |
void foo() |
| 490 |
{ |
| 491 |
Point[N] _ = bar(); |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 495 |
alias test8163!(long) _l; |
| 496 |
alias test8163!(double) _d; |
| 497 |
alias test8163!(float, float) _ff; |
| 498 |
alias test8163!(int, int) _ii; |
| 499 |
alias test8163!(int, float) _if; |
| 500 |
alias test8163!(ushort, ushort, ushort, ushort) _SSSS; |
| 501 |
alias test8163!(ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte) _BBBBBBBB; |
| 502 |
alias test8163!(ubyte, ubyte, ushort, float) _BBSf; |
| 503 |
|
| 504 |
|
| 505 |
/***************************************************/ |
| 506 |
// https://issues.dlang.org/show_bug.cgi?id=4757 |
| 507 |
|
| 508 |
auto foo4757(T)(T) |
| 509 |
{ |
| 510 |
static struct Bar(T) |
| 511 |
{ |
| 512 |
void spam() |
| 513 |
{ |
| 514 |
foo4757(1); |
| 515 |
} |
| 516 |
} |
| 517 |
return Bar!T(); |
| 518 |
} |
| 519 |
|
| 520 |
void test4757() |
| 521 |
{ |
| 522 |
foo4757(1); |
| 523 |
} |
| 524 |
|
| 525 |
/***************************************************/ |
| 526 |
// https://issues.dlang.org/show_bug.cgi?id=9348 |
| 527 |
|
| 528 |
void test9348() |
| 529 |
{ |
| 530 |
@property Object F(int E)() { return null; } |
| 531 |
|
| 532 |
assert(F!0 !is null); |
| 533 |
assert(F!0 !in [new Object():1]); |
| 534 |
} |
| 535 |
|
| 536 |
/***************************************************/ |
| 537 |
// https://issues.dlang.org/show_bug.cgi?id=9690 |
| 538 |
|
| 539 |
@disable |
| 540 |
{ |
| 541 |
void dep9690() {} |
| 542 |
void test9690() |
| 543 |
{ |
| 544 |
dep9690(); // OK |
| 545 |
void inner() |
| 546 |
{ |
| 547 |
dep9690(); // OK <- NG |
| 548 |
} |
| 549 |
} |
| 550 |
} |
| 551 |
|
| 552 |
/***************************************************/ |
| 553 |
// https://issues.dlang.org/show_bug.cgi?id=9987 |
| 554 |
|
| 555 |
static if (is(object.ModuleInfo == struct)) |
| 556 |
{ |
| 557 |
struct ModuleInfo {} |
| 558 |
|
| 559 |
static assert(!is(object.ModuleInfo == ModuleInfo)); |
| 560 |
static assert(object.ModuleInfo.sizeof != ModuleInfo.sizeof); |
| 561 |
} |
| 562 |
static if (is(object.ModuleInfo == class)) |
| 563 |
{ |
| 564 |
class ModuleInfo {} |
| 565 |
|
| 566 |
static assert(!is(object.ModuleInfo == ModuleInfo)); |
| 567 |
static assert(__traits(classInstanceSize, object.ModuleInfo) != |
| 568 |
__traits(classInstanceSize, ModuleInfo)); |
| 569 |
} |
| 570 |
|
| 571 |
/***************************************************/ |
| 572 |
// https://issues.dlang.org/show_bug.cgi?id=10158 |
| 573 |
|
| 574 |
class Outer10158 |
| 575 |
{ |
| 576 |
static struct Inner |
| 577 |
{ |
| 578 |
int f; |
| 579 |
} |
| 580 |
|
| 581 |
void test() |
| 582 |
{ |
| 583 |
static assert( Inner.f .offsetof == 0); // OK <- NG |
| 584 |
static assert((Inner.f).offsetof == 0); // OK |
| 585 |
} |
| 586 |
} |
| 587 |
|
| 588 |
void test10158() |
| 589 |
{ |
| 590 |
static assert(Outer10158.Inner.f.offsetof == 0); // OK |
| 591 |
} |
| 592 |
|
| 593 |
/***************************************************/ |
| 594 |
// https://issues.dlang.org/show_bug.cgi?id=10326 |
| 595 |
|
| 596 |
class C10326 |
| 597 |
{ |
| 598 |
int val; |
| 599 |
invariant { assert(val == 0); } |
| 600 |
invariant() { assert(val == 0); } |
| 601 |
} |
| 602 |
|
| 603 |
/***************************************************/ |
| 604 |
// https://issues.dlang.org/show_bug.cgi?id=11042 |
| 605 |
|
| 606 |
static if ((true || error) == true ) {} else { static assert(0); } |
| 607 |
static if ((false && error) == false) {} else { static assert(0); } |
| 608 |
static assert ((true || error) == true ); |
| 609 |
static assert ((false && error) == false); |
| 610 |
int f11042a1()() if ((true || error) == true ) { return 0; } enum x11042a1 = f11042a1(); |
| 611 |
int f11042b1()() if ((false && error) == false) { return 0; } enum x11042b1 = f11042b1(); |
| 612 |
|
| 613 |
static if (is(typeof(true || error)) == false) {} else { static assert(0); } |
| 614 |
static if (is(typeof(false && error)) == false) {} else { static assert(0); } |
| 615 |
static assert (is(typeof(true || error)) == false); |
| 616 |
static assert (is(typeof(false && error)) == false); |
| 617 |
int f11042a2()() if (is(typeof(true || error)) == false) { return 0; } enum x11042a2 = f11042a2(); |
| 618 |
int f11042b2()() if (is(typeof(false && error)) == false) { return 0; } enum x11042b2 = f11042b2(); |
| 619 |
|
| 620 |
static if (__traits(compiles, true || error) == false) {} else { static assert(0); } |
| 621 |
static if (__traits(compiles, false && error) == false) {} else { static assert(0); } |
| 622 |
static assert (__traits(compiles, true || error) == false); |
| 623 |
static assert (__traits(compiles, false && error) == false); |
| 624 |
int f11042a3()() if (__traits(compiles, true || error) == false) { return 0; } enum x11042a3 = f11042a3(); |
| 625 |
int f11042b3()() if (__traits(compiles, false && error) == false) { return 0; } enum x11042b3 = f11042b3(); |
| 626 |
|
| 627 |
// https://issues.dlang.org/show_bug.cgi?id=24699 |
| 628 |
enum T24699(bool cond) = cond; |
| 629 |
enum b24699a = T24699!(true || error); |
| 630 |
enum b24699b = T24699!(false && error); |
| 631 |
|
| 632 |
/***************************************************/ |
| 633 |
// https://issues.dlang.org/show_bug.cgi?id=11554 |
| 634 |
|
| 635 |
enum E11554; |
| 636 |
static assert(is(E11554 == enum)); |
| 637 |
|
| 638 |
struct Bro11554(N...) {} |
| 639 |
static assert(!is(E11554 unused : Bro11554!M, M...)); |
| 640 |
|
| 641 |
/***************************************************/ |
| 642 |
// https://issues.dlang.org/show_bug.cgi?id=12302 |
| 643 |
|
| 644 |
template isCallable12302(T...) |
| 645 |
if (T.length == 1) |
| 646 |
{ |
| 647 |
static if (is(typeof(& T[0].opCall) == delegate)) |
| 648 |
enum bool isCallable12302 = true; |
| 649 |
else |
| 650 |
static if (is(typeof(& T[0].opCall) V : V*) && is(V == function)) |
| 651 |
enum bool isCallable12302 = true; |
| 652 |
else |
| 653 |
enum bool isCallable12302 = true; |
| 654 |
} |
| 655 |
|
| 656 |
class A12302 |
| 657 |
{ |
| 658 |
struct X {} |
| 659 |
X x; |
| 660 |
auto opDispatch(string s, TArgs...)(TArgs args) |
| 661 |
{ |
| 662 |
mixin("return x."~s~"(args);"); |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
A12302 func12302() { return null; } |
| 667 |
enum b12302 = isCallable12302!func12302; |
| 668 |
|
| 669 |
/***************************************************/ |
| 670 |
// https://issues.dlang.org/show_bug.cgi?id=12476 |
| 671 |
|
| 672 |
template A12476(T) { } |
| 673 |
|
| 674 |
struct S12476(T) |
| 675 |
{ |
| 676 |
alias B = A12476!T; |
| 677 |
} |
| 678 |
|
| 679 |
class C12476(T) |
| 680 |
{ |
| 681 |
alias B = A12476!T; |
| 682 |
} |
| 683 |
|
| 684 |
struct Bar12476(alias Foo) |
| 685 |
{ |
| 686 |
Foo!int baz; |
| 687 |
alias baz this; |
| 688 |
} |
| 689 |
|
| 690 |
alias Identity12476(alias A) = A; |
| 691 |
|
| 692 |
alias sb12476 = Identity12476!(Bar12476!S12476.B); |
| 693 |
alias cb12476 = Identity12476!(Bar12476!C12476.B); |
| 694 |
|
| 695 |
static assert(__traits(isSame, sb12476, A12476!int)); |
| 696 |
static assert(__traits(isSame, cb12476, A12476!int)); |
| 697 |
|
| 698 |
/***************************************************/ |
| 699 |
// https://issues.dlang.org/show_bug.cgi?id=12506 |
| 700 |
|
| 701 |
import imports.a12506; |
| 702 |
private bool[9] r12506a = f12506!(i => true)(); // OK |
| 703 |
private immutable bool[9] r12506b = f12506!(i => true)(); // OK <- error |
| 704 |
|
| 705 |
/***************************************************/ |
| 706 |
// https://issues.dlang.org/show_bug.cgi?id=12555 |
| 707 |
|
| 708 |
class A12555(T) |
| 709 |
{ |
| 710 |
Undef12555 error; |
| 711 |
} |
| 712 |
|
| 713 |
static assert(!__traits(compiles, { |
| 714 |
class C : A12555!C { } |
| 715 |
})); |
| 716 |
|
| 717 |
/***************************************************/ |
| 718 |
// https://issues.dlang.org/show_bug.cgi?id=11622 |
| 719 |
|
| 720 |
class A11622(T) |
| 721 |
{ |
| 722 |
B11622!T foo() |
| 723 |
{ |
| 724 |
return new B11622!T; |
| 725 |
} |
| 726 |
} |
| 727 |
|
| 728 |
class B11622(T) : T |
| 729 |
{ |
| 730 |
} |
| 731 |
|
| 732 |
static assert(!__traits(compiles, { |
| 733 |
class C : A11622!C { } |
| 734 |
})); |
| 735 |
|
| 736 |
/***************************************************/ |
| 737 |
// https://issues.dlang.org/show_bug.cgi?id=12688 |
| 738 |
|
| 739 |
void writeln12688(A...)(A) {} |
| 740 |
|
| 741 |
struct S12688 |
| 742 |
{ |
| 743 |
int foo() @property { return 1; } |
| 744 |
} |
| 745 |
|
| 746 |
void test12688() |
| 747 |
{ |
| 748 |
S12688 s; |
| 749 |
s.foo.writeln12688; // ok |
| 750 |
(s.foo).writeln12688; // ok <- ng |
| 751 |
} |
| 752 |
|
| 753 |
/***************************************************/ |
| 754 |
// https://issues.dlang.org/show_bug.cgi?id=12703 |
| 755 |
|
| 756 |
struct S12703 |
| 757 |
{ |
| 758 |
this(int) {} |
| 759 |
} |
| 760 |
|
| 761 |
final class C12703 |
| 762 |
{ |
| 763 |
S12703 s = S12703(1); |
| 764 |
} |
| 765 |
|
| 766 |
/***************************************************/ |
| 767 |
// https://issues.dlang.org/show_bug.cgi?id=12799 |
| 768 |
|
| 769 |
struct A12799 |
| 770 |
{ |
| 771 |
int a; |
| 772 |
enum C = A12799.sizeof; |
| 773 |
enum D = C; // OK <- Error |
| 774 |
} |
| 775 |
|
| 776 |
/***************************************************/ |
| 777 |
// https://issues.dlang.org/show_bug.cgi?id=13236 |
| 778 |
|
| 779 |
enum bug13286 = is(typeof({ struct S { S x; } })); |
| 780 |
|
| 781 |
/***************************************************/ |
| 782 |
// https://issues.dlang.org/show_bug.cgi?id=13280 |
| 783 |
|
| 784 |
struct S13280 |
| 785 |
{ |
| 786 |
alias U = ubyte; |
| 787 |
alias T1 = ubyte[this.sizeof]; // ok |
| 788 |
alias T2 = const U[this.sizeof]; // ok |
| 789 |
alias T3 = const ubyte[this.sizeof]; // ok <- error |
| 790 |
} |
| 791 |
|
| 792 |
/***************************************************/ |
| 793 |
// https://issues.dlang.org/show_bug.cgi?id=13481 |
| 794 |
|
| 795 |
mixin template Mix13481(void function() callback) |
| 796 |
{ |
| 797 |
static this() |
| 798 |
{ |
| 799 |
callback(); |
| 800 |
} |
| 801 |
} |
| 802 |
|
| 803 |
/***************************************************/ |
| 804 |
// https://issues.dlang.org/show_bug.cgi?id=13564 |
| 805 |
|
| 806 |
class E13564(T) |
| 807 |
{ |
| 808 |
int pos; |
| 809 |
} |
| 810 |
|
| 811 |
class C13564(T) |
| 812 |
{ |
| 813 |
struct S |
| 814 |
{ |
| 815 |
~this() |
| 816 |
{ |
| 817 |
C13564!int c; |
| 818 |
c.element.pos = 0; |
| 819 |
} |
| 820 |
} |
| 821 |
|
| 822 |
E13564!T element; |
| 823 |
} |
| 824 |
|
| 825 |
void test13564() |
| 826 |
{ |
| 827 |
auto c = new C13564!int(); |
| 828 |
} |
| 829 |
|
| 830 |
/***************************************************/ |
| 831 |
// https://issues.dlang.org/show_bug.cgi?id=14166 |
| 832 |
|
| 833 |
struct Proxy14166(T) |
| 834 |
{ |
| 835 |
T* ptr; |
| 836 |
ref deref() { return *ptr; } |
| 837 |
alias deref this; |
| 838 |
} |
| 839 |
struct Test14166 |
| 840 |
{ |
| 841 |
auto opIndex() { return this; } |
| 842 |
auto opIndex(int) { return 1; } |
| 843 |
} |
| 844 |
template Elem14166a(R) { alias Elem14166a = typeof(R.init[][0]); } |
| 845 |
template Elem14166b(R) { alias Elem14166b = typeof(R.init[0]); } |
| 846 |
void test14166() |
| 847 |
{ |
| 848 |
alias T = Proxy14166!Test14166; |
| 849 |
static assert(is(Elem14166a!T == int)); // rejects-valid case |
| 850 |
static assert(is(Elem14166b!T == int)); // regression case |
| 851 |
} |
| 852 |
|
| 853 |
// other related cases |
| 854 |
struct S14166 |
| 855 |
{ |
| 856 |
int x; |
| 857 |
double y; |
| 858 |
int[] a; |
| 859 |
S14166 opUnary(string op : "++")() { return this; } |
| 860 |
} |
| 861 |
S14166 s14166; |
| 862 |
|
| 863 |
struct X14166 { this(int) { } X14166 opAssign(int) { return this; } } |
| 864 |
X14166[int] aa14166; |
| 865 |
ref X14166[int] makeAA14166() { return aa14166; } |
| 866 |
|
| 867 |
struct Tup14166(T...) { T field; alias field this; } |
| 868 |
Tup14166!(int, int) tup14166; |
| 869 |
Tup14166!(int, int) makeTup14166() { return tup14166; } |
| 870 |
alias TT14166(T...) = T; |
| 871 |
|
| 872 |
static assert(is(typeof((s14166.x += 1) = 2) == int)); // ok <- error |
| 873 |
static assert(is(typeof(s14166.a.length += 2) == size_t)); // ok <- error |
| 874 |
static assert(is(typeof(s14166++) == S14166)); // ok <- error |
| 875 |
static assert(is(typeof(s14166.x ^^ 2) == int)); // ok <- error |
| 876 |
static assert(is(typeof(s14166.y ^^= 2.5) == double)); // ok <- error |
| 877 |
static assert(is(typeof(makeAA14166()[0] = 1) == X14166)); // ok <- error |
| 878 |
static assert(is(typeof(tup14166.field = makeTup14166()) == TT14166!(int, int))); // ok <- error |
| 879 |
|
| 880 |
/***************************************************/ |
| 881 |
// https://issues.dlang.org/show_bug.cgi?id=14388 |
| 882 |
|
| 883 |
@property immutable(T)[] idup14388(T)(T[] a) |
| 884 |
{ |
| 885 |
alias U = immutable(T); |
| 886 |
U[] res; |
| 887 |
foreach (ref e; a) |
| 888 |
res ~= e; |
| 889 |
return res; |
| 890 |
} |
| 891 |
|
| 892 |
struct Data14388(A14388 a) |
| 893 |
{ |
| 894 |
auto foo() |
| 895 |
{ |
| 896 |
return Data14388!a.init; // [B] |
| 897 |
} |
| 898 |
} |
| 899 |
|
| 900 |
struct A14388 |
| 901 |
{ |
| 902 |
struct Item {} |
| 903 |
|
| 904 |
immutable(Item)[] items; |
| 905 |
|
| 906 |
this(int dummy) |
| 907 |
{ |
| 908 |
items = [Item()].idup14388; |
| 909 |
} |
| 910 |
} |
| 911 |
|
| 912 |
void test14388() |
| 913 |
{ |
| 914 |
auto test = Data14388!(A14388(42)).init.foo(); // [A] |
| 915 |
/* |
| 916 |
* A(42) is interpreter to a struct literal A([immutable(Item)()]). |
| 917 |
* The internal VarDeclaration with STCmanifest for the Data's template parameteter 'a' |
| 918 |
* calls syntaxCopy() on its ((ExpInitializer *)init)->exp in VarDeclaration::semantic(), |
| 919 |
* and 'immutable(Item)()'->syntaxCopy() had incorrectly removed the qualifier. |
| 920 |
* Then, the arguments of two Data template instances at [A] and [B] had become unmatch, |
| 921 |
* and the second instantiation had created the AST duplication. |
| 922 |
*/ |
| 923 |
} |
| 924 |
|
| 925 |
/***************************************************/ |
| 926 |
// https://issues.dlang.org/show_bug.cgi?id=15163 |
| 927 |
|
| 928 |
void function() func15164(int[] arr) |
| 929 |
{ |
| 930 |
return () { }; |
| 931 |
} |
| 932 |
|
| 933 |
void test15163() |
| 934 |
{ |
| 935 |
auto arr = [[0]]; |
| 936 |
func15164(arr[0])(); |
| 937 |
} |
| 938 |
|
| 939 |
/***************************************************/ |
| 940 |
// https://issues.dlang.org/show_bug.cgi?id=3438 |
| 941 |
|
| 942 |
import core.vararg; |
| 943 |
struct S3438_1 { this(int x, int y = 1) { } } |
| 944 |
struct S3438_2 { this(int x, ...) { } } |
| 945 |
struct S3438_3 { this(int x, int[] arr...) { } } |
| 946 |
struct S3438_4 { this(...) { } } |
| 947 |
struct S3438_5 { this(int[] arr...) { } } |
| 948 |
|
| 949 |
/***************************************************/ |
| 950 |
// https://issues.dlang.org/show_bug.cgi?id=15362 |
| 951 |
|
| 952 |
void func15362() |
| 953 |
{ |
| 954 |
assert(true); |
| 955 |
assert(true,); |
| 956 |
assert(true, "So true"); |
| 957 |
assert(true, "Very, very true",); |
| 958 |
static assert(true); |
| 959 |
static assert(true,); |
| 960 |
static assert(true, "So true"); |
| 961 |
static assert(true, "Very, very true",); |
| 962 |
} |
| 963 |
|
| 964 |
/***************************************************/ |
| 965 |
// https://issues.dlang.org/show_bug.cgi?id=15799 |
| 966 |
|
| 967 |
interface I15799 |
| 968 |
{ |
| 969 |
void funA(); |
| 970 |
|
| 971 |
void funB(int n) |
| 972 |
in { |
| 973 |
assert(n); |
| 974 |
}; // Semicolon is not a part of function declaration. It's an empty declaration. |
| 975 |
} |
| 976 |
|
| 977 |
/***************************************************/ |
| 978 |
// https://issues.dlang.org/show_bug.cgi?id=21163 |
| 979 |
|
| 980 |
struct B21163 |
| 981 |
{ |
| 982 |
void function(scope int) fp; |
| 983 |
} |
| 984 |
|
| 985 |
B21163 b21163 = { |
| 986 |
(scope int x){} |
| 987 |
}; |
| 988 |
|
| 989 |
/***************************************************/ |
| 990 |
// https://issues.dlang.org/show_bug.cgi?id=11624 |
| 991 |
|
| 992 |
interface I11624 |
| 993 |
{ |
| 994 |
void foo(); |
| 995 |
} |
| 996 |
|
| 997 |
static assert(!__traits(compiles, |
| 998 |
{ |
| 999 |
static class C11624 : I11624 { } |
| 1000 |
})); |