Bug 19809 – `override` block affects passing lambda as argument
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-04-16T13:25:55Z
Last change time
2019-04-16T14:47:50Z
Keywords
pull
Assigned to
Eduard Staniloiu
Creator
Eduard Staniloiu
Comments
Comment #0 by edi33416 — 2019-04-16T13:25:55Z
I'm having issues with the following code
```
mixin template Impl(M...)
{
int opCmp(Object o) { return 0; }
}
class C
{
override
{
mixin Impl!("x", "y", ((int x) => &x + 1));
}
}
```
This gives me the error:
Error: delegate `t.C.__lambda2` cannot override a non-virtual function
This should compile.
Contrasting, the following code compiles just fine
```
class B
{
void foo(int function(int) fp) {}
}
class C : B
{
override
{
void foo(int function(int) fp = (int x) => x) {}
}
}
```
Comment #1 by dlang-bot — 2019-04-16T13:49:56Z
@edi33416 created dlang/dmd pull request #9625 "Fix Issue 19809 - override block affects passing lambda as argument" fixing this issue:
- Fix Issue 19809 - override block affects passing lambda as argument
https://github.com/dlang/dmd/pull/9625
Comment #2 by dlang-bot — 2019-04-16T14:47:50Z
dlang/dmd pull request #9625 "Fix Issue 19809 - override block affects passing lambda as argument" was merged into master:
- 68d04983c24598a96a4f76c7638874b73083b9a4 by Eduard Staniloiu:
Fix Issue 19809 - override block affects passing lambda as argument
https://github.com/dlang/dmd/pull/9625