digitalmars.D.bugs - [Issue 11935] New: Allow `ref` in front tuple expansion in `foreach` over range iff `front` returns by `ref`
- d-bugmail puremagic.com (45/45) Jan 15 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11935
https://d.puremagic.com/issues/show_bug.cgi?id=11935 Summary: Allow `ref` in front tuple expansion in `foreach` over range iff `front` returns by `ref` Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: verylonglogin.reg gmail.com 11:49:31 MSK --- Test code: --- import std.typecons; struct S1 { property bool empty(); property Tuple!(int, int) front(); void popFront(); } struct S2 { property bool empty(); property ref Tuple!(int, int) front(); void popFront(); } void main() { static assert( __traits(compiles, { foreach( a, b; S1()) { } })); static assert(!__traits(compiles, { foreach(ref a, ref b; S1()) { } })); static assert( __traits(compiles, { foreach(ref a, ref b; S2()) { } })); } --- This issue is for front tuple expansion only. For regular `foreach` over range see Issue 11934. Also Issue 11929 is a simplified variant proposing just disable `ref` in front tuple expansion case because in general created tuple is a temporary. It should be WONTFIX-ed if this one is fixed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 15 2014