raz / conform / run / StopDivZero.raz

22 lines · 398 B · raw · history · last change 7e721e08

1(* Dividing by zero stops the program. The program ends with status 2, after the procedures registered
2 with Rt.atExit, so that what it wrote is out. *)
3module StopDivZero;
4import Out, Rt;
5
6
7proc bye;
8begin
9 Out.str("bye\n");
10end;
11
12proc main*;
13var a, b: I64;
14begin
15 _ := Rt.atExit(bye);
16 a := 7;
17 b := ARGC() - 1;
18 Out.str("before\n");
19 Out.int(a div b);
20end;
21
22end StopDivZero.