nimble-code / Spin

Explicit state logic model checking tool -- 2002 winner of the ACM System Software Award.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arrays in process arguments

jllang opened this issue · comments

According to the documented grammar, a proctype may have a list of declarations as process arguments. As far as I understand it, int x[3] is a valid declaration. Spin does seem to accept such an argument when declaring a proctype. However, I can't figure out how could I run a process that takes an array as an argument. The following model shows what I mean. I added the errors as comments to their corresponding lines:

proctype foo(int x[3])
{
  int i;
  for (i : 0 .. 2)
  {
    printf("%d\n", x[i])
  }
}

init
{
  int y[3] = {1, 2, 3};
  run foo(); /* missing actual parameters: 'foo' */
  run foo(y); /* missing array index for 'y'	saw '')' = 41' */
  run foo({1,2,3}); /* syntax error	saw ''{' = 123' */
  run foo(y[0], y[1], y[2]) /* array in parameter list, x */
}
/* aborting (ana_stmnt) */

will look into it

It is indeed inconsistent. Currently, an array used as a proctype formal parameter is parsed okay -- the warning is only raised when an instance of the proctype is created. Only at this point is a check done that there is no array hidden anywhere.
You can pass a typedef structure to a proctype in a run statement, but here also the typedef structure cannot contain an array anywhere. It's a limitation that I at some point must have had a plan to remove, but never did so.
So the limitation is in the implementation, not in the grammar -- not that this solves anything for the end-user!
Not sure if it's worth overhauling the code to fix it -- but I will add a clarification in the manpage for proctypes.
Thanks again for all your careful tests and reports!