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);
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.
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.