spinpromela

Promela syntax error: Error: incomplete structure ref 'table' saw 'operator: ='


I have the following typedefs. Pub type keeps two ints, and the pub_table keeps an array of publishers and an int.

typedef pub{
    int nodeid;
    int tid
};

typedef pub_table{
    pub table[TABLE_SIZE];
    int last
};

Then on line pt.table[pt.last] = p; I'm getting an error saying

" Error: incomplete structure ref 'table' saw 'operator: ='"

if
:: node_type == publisher -> 
        pub p;
        p.nodeid = node_id;
        p.tid = topic_id;
        pt.last = pt.last + 1; 
        pt.table[pt.last] = p;
fi

Unfortunately I cannot see what's wrong on that line?


Solution

  • The error was because you can't assign a complete typedef variable in one go. I tried to do that by defining local variable pub p; and then after initializing all fields in p, I tried to assign in one go here pt.table[pt.last] = p. I managed to solve it like that:

    pt.table[pt.last].nodeid = node_id;
    pt.table[pt.last].tid = topic_id;
    

    REF:

    The current Spin implementation imposes the following restrictions on the use of typedef objects. It is not possible to assign the value of a complete typedef object directly to another such object of the same type in a single assignment.