-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
This issue is somewhat similar to #197.
As part of an upcoming paper for OVT-21, ChessVDM, we were discussing some of the performance optimizations made in VDMJ related to VDM++ invariants and reference types. The question of whether indirections were also affected by the issue from #197 was raised.
Trying to test my hypothesis I found the bug in the snippet below.
Description:
Ais a class that holds some datax.Bis a class with a reference to an instance ofA.- C defines a type
BRulethat isBwith an invariant stating the valueB.a.x <> 42. Runnerdefines the test:- An instance
aof typeAis created withx := 1. - An instance
bof typeBis created with a reference toa - An instance
cof typeCis created with a reference tob - The value for
a.xis changed to 42 which is the illegal value for typeBRule - Expected behaviour: Specification fails since invariant for
BRuleis broken. - Actual behaviour: Specification does not fail
- An instance
class A
instance variables
public x : nat1;
operations
public A : nat1 ==> A
A(a) == x := a;
end A
class B
instance variables
public a : A;
operations
public B : A ==> B
B(a_arg) == a := a_arg;
end B
class C
instance variables
public b : BRule;
types
public BRule = B
inv b_arg == b_arg.a.x <> 42;
operations
public C : BRule ==> C
C(b_arg) == b := b_arg;
end C
class Runner
operations
public Run: () ==> ()
Run() ==
(
dcl a:A := new A(1);
dcl b:B := new B(a);
let c = new C(b) in
(
a.x := 42;
IO`print("C: ");
IO`print(c);
IO`print("\nNOTICE: Invariant for BRule broken.\n");
);
)
end Runner
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels