Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/test24353.d

raw
1 // https://issues.dlang.org/show_bug.cgi?id=24353
2
3 /**
4 TEST_OUTPUT:
5 ---
6 fail_compilation/test24353.d(23): Error: mutable method `test24353.S.opApply` is not callable using a `const` object
7 fail_compilation/test24353.d(14): Consider adding `const` or `inout` here
8 ---
9 */
10
11
12 struct S
13 {
14 int opApply(int delegate(int) dg)
15 {
16 return 0;
17 }
18 }
19
20 void example()
21 {
22 const S s;
23 foreach (e; s) {} // Error expected here
24 }