1137
|
1 // $HeadURL$
|
|
2 // $Date$
|
|
3 // $Author$
|
|
4
|
|
5 // @author@ simon hudon <simon_member@pathlink.com>
|
|
6 // @date@ 2006-07-17
|
1489
|
7 // @uri@ http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=7907
|
1137
|
8 // @desc@ foreach on aggregate class in some delegate litterals
|
|
9
|
|
10 module dstress.run.b.bug_declaration_440_C;
|
|
11
|
|
12 int[] status;
|
|
13
|
|
14 class Container {
|
1535
|
15 int opApply (int delegate (ref int) dg) {
|
1137
|
16 int counter = 3;
|
|
17 dg(counter);
|
|
18 counter--;
|
|
19 dg(counter);
|
|
20 return 0;
|
|
21 }
|
|
22 }
|
|
23
|
|
24 int main() {
|
|
25 auto a = (
|
|
26 delegate(){
|
|
27 foreach (i ; new Container()){
|
|
28 status ~= i;
|
|
29 }
|
|
30 }
|
|
31 );
|
|
32
|
|
33 if(status.length != 0){
|
|
34 assert(0);
|
|
35 }
|
|
36
|
|
37 a();
|
|
38
|
|
39 if(status.length != 2){
|
|
40 assert(0);
|
|
41 }
|
|
42 if((status[0] != 3) || (status[1] != 2)){
|
|
43 assert(0);
|
|
44 }
|
|
45
|
|
46 return 0;
|
|
47 }
|