raz / conform / run / ErrorValues.raz

29 lines · 775 B · raw · history · last change 264716cb

1(* Each declaration of an error makes one different from every other,
2 whatever its message; a generic module makes its errors once for
3 each instance. *)
4module ErrorValues;
5import Out, A := Fail(I64), B := Fail(I64), C := Fail(U8);
6
7const
8 One: ERROR = "same";
9 Two: ERROR = "same";
10
11proc yes(name: []const U8; b: BOOL);
12begin
13 Out.str(name);
14 if b then Out.str(" true"); else Out.str(" false"); end;
15 Out.ln;
16end;
17
18proc main*;
19begin
20 yes("One = Two", One = Two);
21 yes("One = One", One = One);
22 yes("One # nil", One # nil);
23 Out.str(MSG(One)); Out.char(' '); Out.str(MSG(Two)); Out.char('[');
24 Out.str(MSG(nil)); Out.str("]\n");
25 yes("same instance", A.Oops = B.Oops);
26 yes("other instance", A.Oops = C.Oops);
27end;
28
29end ErrorValues.