digitalmars.D.bugs - [Issue 24265] New: ref delegate no longer implicitly converts to
- d-bugmail puremagic.com (46/46) Nov 28 2023 https://issues.dlang.org/show_bug.cgi?id=24265
https://issues.dlang.org/show_bug.cgi?id=24265 Issue ID: 24265 Summary: ref delegate no longer implicitly converts to unannotated type Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: regression Priority: P3 Component: dmd Assignee: nobody puremagic.com Reporter: destructionator gmail.com This worked fine on dmd 2.098 (my mainline LTS version) but ceased working some time between that and 2.105 (I don't feel like doing a bisect tonight): ``` void main() { ref int alol(); typeof(&alol) dg; int a; dg = delegate ref() { return a; }; dg() = 5; assert(a == 5); } ``` me arsd:~/test$ dmd-2098 refdg me arsd:~/test$ dmd-master refdg refdg.d(5): Error: cannot implicitly convert expression `__dgliteral4` of type int delegate() pure nothrow nogc ref safe` to `int delegate() ref` refdg.d(5): Error: cannot implicitly convert expression `__dgliteral4` of type int delegate() pure nothrow nogc ref safe` to `int delegate() ref` Fails on the new dmd. If you write out all the attributes on the dg type: ``` void main() { ref int alol() safe nogc nothrow pure; typeof(&alol) dg; int a; dg = delegate ref() { return a; }; dg() = 5; assert(a == 5); } ``` Compiles and runs successfully on both old and new dmd. --
Nov 28 2023