mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
27 lines
547 B
D
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;
|
|
}
|