digitalmars.D.bugs - [Issue 23274] New: [REG2.099] Wrong call resolution (ambiguity) with
- d-bugmail puremagic.com (38/38) Jul 29 2022 https://issues.dlang.org/show_bug.cgi?id=23274
https://issues.dlang.org/show_bug.cgi?id=23274 Issue ID: 23274 Summary: [REG2.099] Wrong call resolution (ambiguity) with const and non-const methods Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: johanengelen weka.io Testcase: ``` struct A { void foo(int delegate(int)) { } void foo(int delegate(int) nothrow) const { } // const void bug() { foo( delegate int(int k) { return 1;} ); } } ``` Compilation with dlang2.098 succeeds. Compilation with dlang2.099 errors with: ``` <source>(7): Error: `example.A.foo` called with argument types `(int delegate(int k) pure nothrow nogc safe)` matches both: <source>(2): `example.A.foo(int delegate(int) _param_0)` and: <source>(4): `example.A.foo(int delegate(int) nothrow _param_0) const` ``` Because `bug` is not const, I would expect that only the non-const `foo` is a candidate. If `nothrow` is removed, indeed that is what is called. Note: replacing `delegate` with `function` errors on all compilers at least back to dlang2.071. --
Jul 29 2022