ldc/tests/codegen/nested_lazy_gh2302.d

18 lines
439 B
D

// RUN: %ldc -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
// RUN: %ldc -run %s
void foo()
{
auto impl(T)(lazy T field)
{
// Make sure `field` is a closure variable with delegate type (LL struct).
// CHECK: %nest.impl = type { { i8*, i32 (i8*)* } }
auto ff() { return field; }
auto a = field;
return ff() + a;
}
auto r = impl(123);
assert(r == 246);
}
void main() { foo(); }