syntax sugar problem
kailiangji opened this issue · comments
Kailiang Ji commented
spin does not work well on the following example. If the type of the chan element is a reference, it works.
active proctype test() {
int i;
chan x = [4] of { int };
x ! 1;
x ! 2;
x ! 3;
x ! 4;
for (i in x) {
printf("i = %d\n", i);
}
}
typedef Int {
int v;
}
active proctype test() {
Int i;
chan x = [4] of { Int };
x ! 1;
x ! 2;
x ! 3;
x ! 4;
for (i in x) {
printf("i = %d\n", i.v);
}
}
nimble-code commented
interesting! will check it
nimble-code commented
It is true that this fails, but the manual page
http://spinroot.com/spin/Man/for.html
mentions this explicitly:
"The third use of the for statement is to retrieve all messages from a channel in sequence. To be able to do this the channel has to be defined in a special way, with a single user-defined type as its contents."