[Issue 24265] New: ref delegate no longer implicitly converts to unannotated type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 29 01:42:05 UTC 2023
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 at puremagic.com
Reporter: destructionator at 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 at arsd:~/test$ dmd-2098 refdg
me at arsd:~/test$ ./refdg # compiles and passes assert
me at 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.
--
More information about the Digitalmars-d-bugs
mailing list