[Issue 21545] [dip1000] cannot assign ref returning delegate to variable with lower attributes
https://issues.dlang.org/show_bug.cgi?id=21545 --- Comment #2 from ag0aep6g --- (In reply to ag0aep6g from comment #1) > int i; > auto dg = delegate ref() @safe => i; > > alias DgFull = ref int delegate() pure nothrow @nogc @safe; > alias DgAuto = typeof(dg); > > pragma(msg, DgFull); /* int delegate() pure nothrow @nogc ref @safe */ > pragma(msg, DgAuto); /* int delegate() pure nothrow @nogc ref @safe */ > pragma(msg, is(DgFull == DgAuto)); /* true; okay */ `DgAuto` actually also has the attributes`scope` and `return`, but they have a special "inferred" marker. That means they're not printed.[1] Apparently, the marker also has an effect on `is(X == Y)`. Still bizarre. [1] https://github.com/dlang/dmd/blob/f341be3de711f9dbb91011e3650f8afc3818ec25/src/dmd/mtype.d#L7131-L7134 --
[Issue 21545] [dip1000] cannot assign ref returning delegate to variable with lower attributes
https://issues.dlang.org/show_bug.cgi?id=21545 ag0aep6g changed: What|Removed |Added CC||ag0ae...@gmail.com --- Comment #1 from ag0aep6g --- Bizarre: void main() { int i; auto dg = delegate ref() @safe => i; alias DgFull = ref int delegate() pure nothrow @nogc @safe; alias DgAuto = typeof(dg); pragma(msg, DgFull); /* int delegate() pure nothrow @nogc ref @safe */ pragma(msg, DgAuto); /* int delegate() pure nothrow @nogc ref @safe */ pragma(msg, is(DgFull == DgAuto)); /* true; okay */ alias DgSafe = ref int delegate() @safe; pragma(msg, is(DgFull : DgSafe)); /* true; okay */ pragma(msg, is(DgAuto : DgSafe)); /* false; wat */ } --
[Issue 21546] ref returning delegate circumvents immutable (@safe won't help)
https://issues.dlang.org/show_bug.cgi?id=21546 Bolpat changed: What|Removed |Added Keywords||accepts-invalid, safe CC||qs.il.paperi...@gmail.com --
[Issue 21546] New: ref returning delegate circumvents immutable (@safe won't help)
https://issues.dlang.org/show_bug.cgi?id=21546 Issue ID: 21546 Summary: ref returning delegate circumvents immutable (@safe won't help) Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: qs.il.paperi...@gmail.com A delegate with return type ref immutable(T) can be used to reassign an immutable(T) as follows: alias DGm = ref int delegate() @safe; alias DGi = ref immutable(int) delegate() @safe; @safe void f() { immutable int i = 0; DGi dgi = ref() => i; DGm[] dgms = [ dgi ]; // why? dgms[0]() = 1; assert(i == 1); // fails, because optimization } @safe void g() { DGm[] dgms; foreach (immutable int i; [0]) { assert(i == 0); // just to be sure DGi dgi = ref() => i; dgms ~= dgi; // why? dgms[0]() = 1; assert(i == 1); // passes, meaning immutable i was changed } } The lines marked with // why? should be rejected by the type system. --
[Issue 16058] `immutable delegate()` and `immutable delegate() immutable` are considered equal but treated differently
https://issues.dlang.org/show_bug.cgi?id=16058 Bolpat changed: What|Removed |Added CC||qs.il.paperi...@gmail.com --
[Issue 21545] [dip1000] cannot assign ref returning delegate to variable with lower attributes
https://issues.dlang.org/show_bug.cgi?id=21545 Bolpat changed: What|Removed |Added Keywords||rejects-valid CC||qs.il.paperi...@gmail.com --
[Issue 21545] New: [dip1000] cannot assign ref returning delegate to variable with lower attributes
https://issues.dlang.org/show_bug.cgi?id=21545 Issue ID: 21545 Summary: [dip1000] cannot assign ref returning delegate to variable with lower attributes Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: qs.il.paperi...@gmail.com Using -preview=dip1000, one cannot assign e.g. a pure delegate to a delegate type variable without pure annotation: void main() { int i; alias DG = ref int delegate() @safe; DG dg = delegate ref() @safe => i; } This errors on the assignment of DG. Without the preview switch, it compiles. --
[Issue 19962] [DIP1000] scope on delegate no affect with DIP1000
https://issues.dlang.org/show_bug.cgi?id=19962 Bolpat changed: What|Removed |Added Status|NEW |RESOLVED CC||qs.il.paperi...@gmail.com Resolution|--- |FIXED --- Comment #1 from Bolpat --- Has been fixed in 2.092.1. --