www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19809] New: `override` block affects passing lambda as argument

https://issues.dlang.org/show_bug.cgi?id=19809

          Issue ID: 19809
           Summary: `override` block affects passing lambda as argument
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: edi33416 gmail.com

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) {}
    }
}
```

--
Apr 16 2019