dmd/compiler/test/fail_compilation/opapplyscope.d
Dennis a3abf1187e
Fix 23722 - Lambdas are mangled incorrectly when using multiple compi… (#15343)
* Fix 23722 - Lambdas are mangled incorrectly when using multiple compilation units, resulting in incorrect code

* Update test cases
2024-11-27 12:03:16 +01:00

26 lines
679 B
D

/* TEST_OUTPUT:
---
fail_compilation/opapplyscope.d(113): Error: function `opapplyscope.S.opApply(scope int delegate(scope int* ptr) @safe dg)` is not callable using argument types `(int delegate(int* x) nothrow @nogc @safe)`
fail_compilation/opapplyscope.d(113): cannot pass argument `__foreachbody_L113_C5` of type `int delegate(int* x) nothrow @nogc @safe` to parameter `scope int delegate(scope int* ptr) @safe dg`
---
*/
#line 100
struct S
{
int opApply(scope int delegate (scope int* ptr) @safe dg) @safe
{
return 0;
}
}
void test() @safe
{
static int* global;
S s;
foreach (/*scope*/ int* x; s)
{
global = x;
}
}