www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19211] New: [REG 2.072] cant get the type of a non-const

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

          Issue ID: 19211
           Summary: [REG 2.072] cant get the type of a non-const delegate
                    in a const function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

This used to be possible:


struct Foo
{
    void func1(){}
    void func2() const 
    {alias Fun = typeof(&func1);}  
}

until FE 2.072 but now produces the following error message:

 Error: mutable method `Foo.func1` is not callable using a `const` `this`
What's sure: - this should work always inside `typeof()` since the intention is not to use the delegate. - the error message is wrong for the same reason. What's less sure: - should `&func1` always working as long as not called ? For now the following workaround has to be used: alias Fun = typeof(&(cast()this).func1); --
Sep 01 2018