[Issue 21913] New: [Statements] foreach (index,value;range); sugar is undocumented and narrow

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 10 20:35:06 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21913

          Issue ID: 21913
           Summary: [Statements] foreach (index,value;range); sugar is
                    undocumented and narrow
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dlang.org
          Assignee: nobody at puremagic.com
          Reporter: crazymonkyyy at gmail.com

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

--


More information about the Digitalmars-d-bugs mailing list