/
bug-2015-04-21.dats
92 lines (80 loc) · 1.53 KB
/
bug-2015-04-21.dats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
(*
** Bug causing erroneous
** compilation of tuple pattern matching
*)
(* ****** ****** *)
(*
** Source:
** Reported by kiwamu-2015-04-21
** Symptom: match2(0, 1) returns **
** Symptom: match2(1, 1) returns **
*)
(* ****** ****** *)
(*
** Status: It is fixed by HX-2015-04-21
** See: patcomplst_subtest: auxlst2: PTCMPreclparen
*)
(* ****** ****** *)
fun
match1
(
a:int, b:int
) :void =
(
case+ (a, b) of
| (0, 0) => println! "00"
| (0, 1) => println! "01"
| (1, 1) => println! "11"
| (_, _) => println! "**"
)
(* ****** ****** *)
fun
match2
(
a: int, b: int
) :void =
(
case+ @(a, b) of
| @(0, 0) => println! "00"
| @(0, 1) => println! "01"
| @(1, 1) => println! "11"
| _ (*rest*) => println! "**"
)
(* ****** ****** *)
//
datatype
P(a:t@ype, b:t@ype) = P of (a, b)
//
fun
match3
(
a: int, b: int
) :void =
(
case+ P(a,b) of
| P(0, 0) => println! "00"
| P(0, 1) => println! "01"
| P(1, 1) => println! "11"
| _ (*rest*) => println! "**"
)
//
(* ****** ****** *)
implement
main0 () =
{
//
val () = (print! "match1(0, 0) = "; match1(0, 0))
val () = (print! "match1(0, 1) = "; match1(0, 1))
val () = (print! "match1(1, 1) = "; match1(1, 1))
//
val () = (print! "match2(0, 0) = "; match2(0, 0))
val () = (print! "match2(0, 1) = "; match2(0, 1))
val () = (print! "match2(1, 1) = "; match2(1, 1))
//
val () = (print! "match3(0, 0) = "; match3(0, 0))
val () = (print! "match3(0, 1) = "; match3(0, 1))
val () = (print! "match3(1, 1) = "; match3(1, 1))
//
} (* end of [main0] *)
(* ****** ****** *)
(* end of [bug-2015-04-21.dats] *)