digitalmars.D.bugs - [Issue 22799] New: opApply() delegates not required to be scope
- d-bugmail puremagic.com (28/28) Feb 20 2022 https://issues.dlang.org/show_bug.cgi?id=22799
https://issues.dlang.org/show_bug.cgi?id=22799 Issue ID: 22799 Summary: opApply() delegates not required to be scope Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com The spec https://dlang.org/spec/statement.html#foreach_over_struct_and_classes shows the delegate to be declared as `scope`. But the compiler does not enforce it: struct S { int opApply (/*scope*/ int delegate (int* ptr) safe dg) safe { return 0; } } void test(S s) safe { foreach (int* x; s) { } } compiles without error. --
Feb 20 2022