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

          Issue ID: 22915
           Summary: Errors for invalid foreach aggregates should print the
                    type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

The error message for `foreach` over unusupported types print a rather
unhelpful error message that only lists (parts of) the expression. But it isn't
always obvious, why the expression doesn't yield an iterable value, e.g.:

struct S
{
    int opApply(scope int delegate(const int) dg);
}

S* someFunc();

void foo()
{
    foreach (const i; someFunc()) // Pointer to S, needs dereference
    {
        // ...
    }
}

--

Reply via email to