[Issue 22915] New: Errors for invalid foreach aggregates should print the type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 23 17:07:59 UTC 2022
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: nobody at puremagic.com
Reporter: moonlightsentinel at 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
{
// ...
}
}
--
More information about the Digitalmars-d-bugs
mailing list