Bug 21913 – [Statements] foreach (index,value;range); sugar is undocumented and narrow

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P3
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-10T20:35:06Z
Last change time
2022-10-05T15:16:54Z
Keywords
spec
Assigned to
No Owner
Creator
crazymonkyyy

Comments

Comment #0 by crazymonkyyy — 2021-05-10T20:35:06Z
if you attempt to return a Voldemort type that defines value or index as a function, or stores it in a struct when you call for each you get an error like auto front{ struct dataaccess{ int index; T value; } return dataacess(start,data[start]); } >Error: cannot infer argument types, expected 1 argument, not 2 It seems to require exactly an std.tuple, and the spec should say as much or clarify how it works
Comment #1 by destructionator — 2021-05-10T20:42:25Z
it is a compiler-tuple it needs. std.tuple has alias this to a compiler-tuple. this is the same as any other function call. compiler-tuples can expand to argument lists.
Comment #2 by nick — 2022-10-05T15:16:06Z