raz / test / run / IfReturnEnds.raz

24 lines · 465 B · raw · history · last change 2e254a62

1(* An if that ends a procedure, its body ending in return: the jump past
2 the if lands at the procedure's return, not beyond it. *)
3module IfReturnEnds;
4import Sys;
5
6var keys: [1]INT;
7
8proc f(on: BOOL);
9begin
10 if on and (keys[0] > 0) then
11 keys[0] := 2;
12 return;
13 end;
14end;
15
16proc main*;
17begin
18 f(false);
19 keys[0] := 1;
20 f(true);
21 if keys[0] # 2 then Sys.exit(1); end;
22 _ := Sys.write(Sys.stdout, "ok\n");
23end;
24end IfReturnEnds.