| 1 |
/* |
| 2 |
REQUIRED_ARGS: -preview=dip1000 |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/test23982.d(35): Error: assigning scope variable `a` to non-scope parameter `a` calling `foo2` is not allowed in a `@safe` function |
| 6 |
fail_compilation/test23982.d(26): which is not `scope` because of `b = a` |
| 7 |
--- |
| 8 |
*/ |
| 9 |
// https://issues.dlang.org/show_bug.cgi?id=23982 |
| 10 |
// Issue 23982 - segfault when printing scope inference failure |
| 11 |
@safe: |
| 12 |
|
| 13 |
struct B() |
| 14 |
{ |
| 15 |
this(int* a) |
| 16 |
{ |
| 17 |
this.a = a; |
| 18 |
} |
| 19 |
int* a; |
| 20 |
} |
| 21 |
|
| 22 |
class C() |
| 23 |
{ |
| 24 |
int* foo2(int* a) |
| 25 |
{ |
| 26 |
auto b = B!()(a); |
| 27 |
return b.a; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
void main() |
| 32 |
{ |
| 33 |
scope int* a; |
| 34 |
C!() c; |
| 35 |
c.foo2(a); |
| 36 |
} |