d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail118.d
bloba526b908acdbe69d92c81d035843f8ba4255f74b
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail118.d(45): Error: invalid `foreach` aggregate `Iter` of type `Iter`
5 fail_compilation/fail118.d(45): `foreach` works with input ranges (implementing `front` and `popFront`), aggregates implementing `opApply`, or the result of an aggregate's `.tupleof` property
6 fail_compilation/fail118.d(45): https://dlang.org/phobos/std_range_primitives.html#isInputRange
7 fail_compilation/fail118.d(46): Error: invalid `foreach` aggregate `Iter` of type `Iter`
8 fail_compilation/fail118.d(46): `foreach` works with input ranges (implementing `front` and `popFront`), aggregates implementing `opApply`, or the result of an aggregate's `.tupleof` property
9 fail_compilation/fail118.d(46): https://dlang.org/phobos/std_range_primitives.html#isInputRange
10 fail_compilation/fail118.d(49): Error: invalid `foreach` aggregate `s` of type `S*`
11 fail_compilation/fail118.d(51): Error: undefined identifier `unknown`
12 fail_compilation/fail118.d(39): Error: undefined identifier `doesNotExist`
13 fail_compilation/fail118.d(53): Error: template instance `fail118.error!()` error instantiating
14 fail_compilation/fail118.d(53): Error: invalid `foreach` aggregate `error()` of type `void`
15 ---
18 // https://issues.dlang.org/show_bug.cgi?id=441
19 // Crash on foreach of mixed-in aggregate.
20 template opHackedApply()
22 struct Iter
27 class Foo
29 mixin opHackedApply!() oldIterMix;
32 struct S
34 int opApply(scope int delegate(const int) dg);
37 auto error()()
39 doesNotExist();
42 void main()
44 Foo f = new Foo;
45 foreach (int i; f.oldIterMix.Iter) {}
46 foreach ( i; f.oldIterMix.Iter) {}
48 S* s;
49 foreach (const i; s) {}
51 foreach(const i; unknown) {}
53 foreach (const i; error()) {}