overture icon indicating copy to clipboard operation
overture copied to clipboard

Object arguments are not seen as state

Open nickbattle opened this issue 9 years ago • 1 comments

There is a problem with object references passed as arguments to operations, because parameters are always treated as non-state values, whereas object do contain state. So for example, the following spec produces an error, saying that obj cannot be accessed as state from this context.

class A
instance variables
    public iv:nat := 0;

operations
    public test: A ==> ()
    test(obj) == obj.iv := 0;

end A

The solution is just to treat class parameter types as NameScope STATE rather than LOCAL.

nickbattle avatar Sep 02 '16 07:09 nickbattle

This has been fixed in VDMJ, but Overture is still wrong. I'll take a look (not before 2.5.2 though)

nickbattle avatar Sep 05 '17 13:09 nickbattle