dmd/compiler/test/fail_compilation/diag15411.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

27 lines
995 B
D

// REQUIRED_ARGS: -o-
/*
TEST_OUTPUT:
---
fail_compilation/diag15411.d(17): Error: function `diag15411.test15411.__funcliteral_L17_C15` cannot access variable `i` in frame of function `diag15411.test15411`
fail_compilation/diag15411.d(16): `i` declared here
fail_compilation/diag15411.d(18): Error: function `diag15411.test15411.__funcliteral_L18_C15` cannot access variable `i` in frame of function `diag15411.test15411`
fail_compilation/diag15411.d(16): `i` declared here
fail_compilation/diag15411.d(26): Error: `static` function `diag15411.testNestedFunction.myFunc2` cannot access function `myFunc1` in frame of function `diag15411.testNestedFunction`
fail_compilation/diag15411.d(25): `myFunc1` declared here
---
*/
void test15411()
{
auto i = 0;
auto j = (function() { return i; })();
auto f = function() { return i; };
}
void testNestedFunction ()
{
int i = 42;
void myFunc1() { assert(i == 42); }
static void myFunc2 () { myFunc1(); }
}