Bug 20823 – [DIP 1000] un-@safe code fails with dip1000

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-05-12T08:05:25Z
Last change time
2022-07-26T07:57:27Z
Keywords
pull, Vision
Assigned to
No Owner
Creator
Juraj

Comments

Comment #0 by zero — 2020-05-12T08:05:25Z
Adding -preview=dip1000 breaks code that is not annotated as @safe. void boo(T)(T[] data, scope void delegate(T[] data) @nogc fun) { fun(data); } void goo(T)(T[] data, /+scope+/ void delegate(T[] data) @nogc fun) { fun(data); } int[256] arr; void main() { void Execute(T)(T[] data) @nogc { // ... } // Works goo(arr[0..$], &Execute!int); // Compiler error with DIP 1000 boo(arr[0..$], &Execute!int); } --- Error: template onlineapp.boo cannot deduce function from argument types !()(int[], void delegate(int[] data) pure nothrow @nogc @safe), candidates are: onlineapp.d(2): boo(T)(T[] data, scope void delegate(T[] data) @nogc fun) --- https://run.dlang.io/is/mvYgJ9
Comment #1 by dkorpel — 2021-07-11T23:52:51Z
Reduced a bit more: ``` void boo(T)( scope void delegate(T[] data) fun) {} void goo(T)(/+scope+/ void delegate(T[] data) fun) {} void main() { void Execute(int[] data) {} goo(&Execute); // Works boo(&Execute); // Compiler error with DIP 1000 } ```
Comment #2 by dlang-bot — 2022-07-25T22:09:57Z
@dkorpel created dlang/dmd pull request #14331 "Fix 20823 - un-@safe code fails with dip1000" fixing this issue: - Fix 20823 - un-@safe code fails with dip1000 https://github.com/dlang/dmd/pull/14331
Comment #3 by dlang-bot — 2022-07-26T07:57:27Z
dlang/dmd pull request #14331 "Fix 20823 - un-@safe code fails with dip1000" was merged into master: - bc49666578e6c40a73a0974a0a42186a5fbccd6e by Dennis Korpel: Fix 20823 - un-@safe code fails with dip1000 https://github.com/dlang/dmd/pull/14331