Bug 11935 – Allow `ref` in front tuple expansion in `foreach` over range iff `front` returns by `ref`

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-15T23:49:31Z
Last change time
2024-12-13T18:16:07Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Denis Shelomovskii
See also
https://issues.dlang.org/show_bug.cgi?id=11934
Moved to GitHub: dmd#18760 →

Comments

Comment #0 by verylonglogin.reg — 2014-01-15T23:49:31Z
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.
Comment #1 by robert.schadek — 2024-12-13T18:16:07Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18760 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB