Thread overview
[Issue 19211] [REG 2.072] cant get the type of a non-const delegate in a const function
Dec 13, 2018
Walter Bright
[Issue 19211] get the type of a non-const delegate in a const function
Dec 13, 2018
Walter Bright
Dec 23, 2019
Basile-z
December 13, 2018
https://issues.dlang.org/show_bug.cgi?id=19211

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
I'm not so sure this is a good idea to change this, as changing it could destabilize the type checking inside the typeof().

(It is erroneous code - the type checking is working as designed.)

The error message is not exactly wrong, though it could be improved. Changed to enhancement request.

--
December 13, 2018
https://issues.dlang.org/show_bug.cgi?id=19211

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[REG 2.072] cant get the    |get the type of a non-const
                   |type of a non-const         |delegate in a const
                   |delegate in a const         |function
                   |function                    |
           Severity|regression                  |enhancement

--
December 23, 2019
https://issues.dlang.org/show_bug.cgi?id=19211

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
let's close.

one can do, instead of using &func1 which is contaminated by transitive const.
---
struct Foo
{
    void func1(){}
    void func2() const {alias Fun = typeof(&(new Foo).func1);}
}
---

The problem pointed by the original report is more that people don't understand how `const` works, i.e in a `const` function, `this` becomes `const` and is propagated by transitivity, which is even something I pointed in a blog post in after reporting.

--