dmd/compiler/test/fail_compilation/fail20551.d
Dennis 9b94878c85
Make safe error messages consistent (#20654)
Co-authored-by: Dennis Korpel <dennis@sarc.nl>
2025-01-08 13:46:38 +08:00

27 lines
547 B
D

/*
TEST_OUTPUT:
---
fail_compilation/fail20551.d(15): Error: taking address of lazy parameter `e` is not allowed in a `@safe` function
fail_compilation/fail20551.d(26): Error: template instance `fail20551.LazyStore!int.LazyStore.opAssign!int` error instantiating
---
*/
struct LazyStore(T)
{
T delegate() @safe dg;
void opAssign(E)(lazy E e) @safe
{
dg = cast(typeof(dg)) &e;
}
T test() @safe{ return dg(); }
}
static LazyStore!int f;
void main(string[] args) @safe
{
int x = 1;
f = x + x + 20 + x * 20;
}