www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22915] New: Errors for invalid foreach aggregates should


          Issue ID: 22915
           Summary: Errors for invalid foreach aggregates should print the
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

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
        // ...

Mar 23 2022