mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-14 15:16:07 +03:00

Don't simply forward the caller's context without checking whether the lambda actually needs a parent context. Fixes #3553.
16 lines
283 B
D
16 lines
283 B
D
// https://github.com/ldc-developers/ldc/issues/3553
|
|
// RUN: %ldc -run %s
|
|
|
|
auto makeDelegate(alias fn)(long l) {
|
|
auto callIt() {
|
|
return fn() * l;
|
|
}
|
|
return &callIt;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
int i = 7;
|
|
auto dg = makeDelegate!(() => i)(3);
|
|
assert(dg() == 21);
|
|
}
|