D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21913 - [Statements] foreach (index,value;range); sugar is undocumented and narrow
Summary: [Statements] foreach (index,value;range); sugar is undocumented and narrow
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P3 enhancement
Assignee: No Owner
URL: http://dlang.org/
Keywords: spec
Depends on:
Blocks:
 
Reported: 2021-05-10 20:35 UTC by crazymonkyyy
Modified: 2022-10-05 15:16 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description crazymonkyyy 2021-05-10 20:35:06 UTC
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 Adam D. Ruppe 2021-05-10 20:42:25 UTC
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.