mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00

* Fix 23722 - Lambdas are mangled incorrectly when using multiple compilation units, resulting in incorrect code * Update test cases
35 lines
987 B
D
35 lines
987 B
D
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/var_func_attr.d(19): Error: cannot implicitly convert expression `__lambda_L19_C27` of type `void function() nothrow @nogc @safe` to `void function() pure`
|
|
---
|
|
*/
|
|
|
|
// Test the effect of function attributes on variables
|
|
// See:
|
|
// https://issues.dlang.org/show_bug.cgi?id=7432
|
|
// https://github.com/dlang/dmd/pull/14199
|
|
// Usually it's a no-op, but the attribute can apply to the function/delegate type of the variable
|
|
// The current behavior is weird, so this is a test of the current behavior, not necessarily the desired behavior
|
|
|
|
// No-op
|
|
pure int x;
|
|
|
|
// Applies to function type (existing code in dmd and Phobos relies on this)
|
|
pure void function() pf = () {
|
|
static int g;
|
|
g++;
|
|
};
|
|
|
|
// Function attributes currently don't apply to inferred types (somewhat surprisingly)
|
|
nothrow nf = () {
|
|
throw new Exception("");
|
|
};
|
|
|
|
// Neither do they apply to indirections
|
|
alias F = void function();
|
|
|
|
pure F pf2 = () {
|
|
static int g;
|
|
g++;
|
|
};
|