| 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. *) |
| 4 | module ErrorValues; |
| 5 | import Out, A := Fail(I64), B := Fail(I64), C := Fail(U8); |
| 6 | |
| 7 | const |
| 8 | One: ERROR = "same"; |
| 9 | Two: ERROR = "same"; |
| 10 | |
| 11 | proc yes(name: []const U8; b: BOOL); |
| 12 | begin |
| 13 | Out.str(name); |
| 14 | if b then Out.str(" true"); else Out.str(" false"); end; |
| 15 | Out.ln; |
| 16 | end; |
| 17 | |
| 18 | proc main*; |
| 19 | begin |
| 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); |
| 27 | end; |
| 28 | |
| 29 | end ErrorValues. |