Bug 20121 – "template lambda has no value" when assigned to struct
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-08-11T18:51:06Z
Last change time
2021-10-27T22:25:52Z
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2019-08-11T18:51:06Z
Lambdas don't correctly decay to functions or delegates when assigned via opAssign, but do so correctly for regular functions and member functions, even calling opAssign directly, and with property syntax:
unittest {
S s;
s.opAssign(i => i + 1); // Works
s.opAssign = i => i + 1; // Works
s = i => i + 1; // Fails (template lambda has no value)
}
struct S {
void opAssign(int delegate(int) fn) {}
void opAssign(int function(int) fn) {}
}