Skip to content

Commit 6ea1e7e

Browse files
authored
Fix probes breaking pattern matching statics and dynamics (#2044)
2 parents 8fab0ba + 3156979 commit 6ea1e7e

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/language/dynamics/transition/PatternMatch.re

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ let rec matches = (capture, dp: Pat.t, d: DHExp.t): match_result => {
4444
| Constructor(ctr, _) =>
4545
let* () = Unboxing.unbox(SumNoArg(ctr), d);
4646
Matches([]);
47-
| Ap({term: Constructor(ctr, _), _}, p2) =>
48-
let* d2 = Unboxing.unbox(SumWithArg(ctr), d);
49-
matches(p2, d2);
50-
| Ap(_, _) => IndetMatch // TODO: should this fail?
47+
| Ap(c, p2) =>
48+
switch (Pat.ctr_name(c)) {
49+
| Some(ctr) =>
50+
let* d2 = Unboxing.unbox(SumWithArg(ctr), d);
51+
matches(p2, d2);
52+
| None => IndetMatch
53+
}
5154
| Var(x) => Matches([(x, d)])
5255
/* Labels are a special case */
5356
| Label(name) =>

src/language/statics/Statics.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,8 +1909,8 @@ and upat_to_info_map =
19091909
let fn_ana = Arrow(syn, ana) |> Typ.temp;
19101910
let (fn', m) = go(~ctx, ~ana=fn_ana, fn, m);
19111911
let m = {
1912-
switch (fn |> Pat.term_of) {
1913-
| Constructor(_) => m
1912+
switch (ctr) {
1913+
| Some(_) => m
19141914
| _ =>
19151915
let info =
19161916
Info.derived_pat(

src/language/term/Pat.re

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ let rec get_num_of_vars = (pat: t) =>
238238

239239
let ctr_name = (p: t): option(Constructor.t) =>
240240
switch (p.term) {
241-
| Constructor(name, _) => Some(name)
241+
| Constructor(name, _)
242+
| Parens({term: Constructor(name, _), _})
243+
| Probe({term: Constructor(name, _), _}, _) => Some(name)
242244
| _ => None
243245
};
244246

0 commit comments

Comments
 (0)