Skip to content

Commit b4ddb31

Browse files
committed
Fix missing unbox
1 parent 3cbde5f commit b4ddb31

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/chc/unbox.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,42 @@ fn unbox_term(term: Term) -> Term {
1313
Term::App(fun, args) => Term::App(fun, args.into_iter().map(unbox_term).collect()),
1414
Term::Tuple(ts) => Term::Tuple(ts.into_iter().map(unbox_term).collect()),
1515
Term::TupleProj(t, i) => Term::TupleProj(Box::new(unbox_term(*t)), i),
16-
Term::DatatypeCtor(s1, s2, args) => {
17-
Term::DatatypeCtor(s1, s2, args.into_iter().map(unbox_term).collect())
18-
}
16+
Term::DatatypeCtor(s1, s2, args) => Term::DatatypeCtor(
17+
unbox_datatype_sort(s1),
18+
s2,
19+
args.into_iter().map(unbox_term).collect(),
20+
),
1921
Term::DatatypeDiscr(sym, arg) => Term::DatatypeDiscr(sym, Box::new(unbox_term(*arg))),
2022
Term::FormulaExistentialVar(sort, name) => {
2123
Term::FormulaExistentialVar(unbox_sort(sort), name)
2224
}
2325
}
2426
}
2527

28+
fn unbox_matcher_pred(pred: MatcherPred) -> Pred {
29+
let MatcherPred {
30+
datatype_symbol,
31+
datatype_args,
32+
} = pred;
33+
let datatype_args = datatype_args.into_iter().map(unbox_sort).collect();
34+
Pred::Matcher(MatcherPred {
35+
datatype_symbol,
36+
datatype_args,
37+
})
38+
}
39+
40+
fn unbox_pred(pred: Pred) -> Pred {
41+
match pred {
42+
Pred::Known(pred) => Pred::Known(pred),
43+
Pred::Var(pred) => Pred::Var(pred),
44+
Pred::Matcher(pred) => unbox_matcher_pred(pred),
45+
}
46+
}
47+
2648
fn unbox_atom(atom: Atom) -> Atom {
2749
let Atom { guard, pred, args } = atom;
2850
let guard = guard.map(|fo| Box::new(unbox_formula(*fo)));
51+
let pred = unbox_pred(pred);
2952
let args = args.into_iter().map(unbox_term).collect();
3053
Atom { guard, pred, args }
3154
}

0 commit comments

Comments
 (0)