Bug 22388 – Wrong overload selected for @safe delegate
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-10-14T23:31:04Z
Last change time
2021-10-21T21:39:29Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel
Comments
Comment #0 by moonlightsentinel — 2021-10-14T23:31:04Z
The following code fails to compile because the compiler selects the compiler wrongly selects the first overload instead of the second one:
void setTimer(void delegate() callback) @system;
void setTimer(void delegate() @safe callback) @safe;
void main() @safe
{
alias lambda = { assert(false); };
setTimer(lambda);
}
Comment #1 by dlang-bot — 2021-10-14T23:58:20Z
@MoonlightSentinel created dlang/dmd pull request #13170 "Fix 22388 - Don't discard function safety when matching lambdas" fixing this issue:
- Fix 22388 - Don't discard function safety when matching lambdas
The code intended to copy the `TypeFunction` and change the return
type but also dropped the safety level.
https://github.com/dlang/dmd/pull/13170
Comment #2 by dlang-bot — 2021-10-15T02:23:46Z
dlang/dmd pull request #13170 "Fix 22388 - Don't discard function safety when matching lambdas" was merged into stable:
- e5a221a5f92fbb121b422639f99af7c6ed2acad5 by MoonlightSentinel:
Fix 22388 - Don't discard function safety when matching lambdas
The code intended to copy the `TypeFunction` and change the return
type but also dropped the safety level.
https://github.com/dlang/dmd/pull/13170
Comment #3 by dlang-bot — 2021-10-21T21:39:29Z
dlang/dmd pull request #13209 "Merge stable into master" was merged into master:
- 59288c7a3cdd661113c3b1d63b22fce66e1b50ae by MoonlightSentinel:
Fix 22388 - Don't discard function safety when matching lambdas
The code intended to copy the `TypeFunction` and change the return
type but also dropped the safety level.
https://github.com/dlang/dmd/pull/13209