File: function-modifying.m

package info (click to toggle)
rumur 2025.08.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,644 kB
  • sloc: cpp: 18,711; ansic: 3,825; python: 1,578; objc: 1,542; yacc: 568; sh: 331; lex: 241; lisp: 15; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 876 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- call to a function that also takes a var parameter
--
-- While developing murphi2uclid, it emerged that an interesting case was a call
-- to a value-returning function where the function itself also took a var
-- parameter. Examples of this existed elsewhere in the test suite, but only in
-- combination with other features not accepted by murph2uclid. This example is
-- intended to be acceptable by murphi2uclid, but still exhibit this described
-- behaviour.

var
  x: boolean;
  z: boolean;

function foo(var y: boolean): boolean; begin
  -- we cannot actually modify y and still have this model acceptable to
  -- murphi2uclid (yes, this is a pretty weird edge case)
  return !y;
end;

startstate begin
  x := true;
  z := true;
end;

rule begin
  -- call the function and store its return value, but also pass it something
  -- mutable
  z := foo(x);
  x := z;
end;