| 1 |
// https://issues.dlang.org/show_bug.cgi?id=22865 |
| 2 |
|
| 3 |
// Test that safety errors inside speculative scopes don't affect attribute inference |
| 4 |
|
| 5 |
void main() @safe |
| 6 |
{ |
| 7 |
foo(); |
| 8 |
} |
| 9 |
|
| 10 |
__gshared int g; |
| 11 |
|
| 12 |
auto foo() |
| 13 |
{ |
| 14 |
alias x0 = typeof(g++); |
| 15 |
alias x1 = typeof(cast(int*) 0); |
| 16 |
|
| 17 |
auto x2 = __traits(compiles, g++); |
| 18 |
enum x3 = __traits(compiles, (cast(int*) 0)); |
| 19 |
|
| 20 |
debug |
| 21 |
{ |
| 22 |
g++; |
| 23 |
const x4 = cast(int*) 0; |
| 24 |
asm { } |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
// Test that safety violations still occur if the function is inside the __traits(compiles) |
| 29 |
|
| 30 |
static assert(!__traits(compiles, { |
| 31 |
void f() @safe |
| 32 |
{ |
| 33 |
g++; |
| 34 |
} |
| 35 |
})); |