| 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. *) |
| 3 | module IfReturnEnds; |
| 4 | import Sys; |
| 5 | |
| 6 | var keys: [1]INT; |
| 7 | |
| 8 | proc f(on: BOOL); |
| 9 | begin |
| 10 | if on and (keys[0] > 0) then |
| 11 | keys[0] := 2; |
| 12 | return; |
| 13 | end; |
| 14 | end; |
| 15 | |
| 16 | proc main*; |
| 17 | begin |
| 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"); |
| 23 | end; |
| 24 | end IfReturnEnds. |