Skip to content

Commit

Permalink
[sc-301] Fix after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
developedby committed Feb 27, 2024
1 parent 5f2d835 commit 4c8a9f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/term/transform/float_combinators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl Term {

for rule in rules.iter_mut() {
for pat in &rule.pats {
debug_assert!(pat.is_detached_num_match());
debug_assert!(pat.is_native_num_match());
}

let arm_detach = match rule.body.go_float(depth + 1, term_info) {
Expand Down
21 changes: 7 additions & 14 deletions src/term/transform/linearize_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Ctx<'_> {

for (def_name, def) in self.book.defs.iter_mut() {
for rule in def.rules.iter_mut() {
let res = rule.body.linearize_simple_matches(&self.book.ctrs, lift_all_vars);
let res = rule.body.linearize_simple_matches(lift_all_vars);
self.info.take_err(res, Some(def_name));
}
}
Expand All @@ -23,24 +23,17 @@ impl Ctx<'_> {
}

impl Term {
fn linearize_simple_matches(&mut self, ctrs: &Constructors, lift_all_vars: bool) -> Result<(), MatchErr> {
fn linearize_simple_matches(&mut self, lift_all_vars: bool) -> Result<(), MatchErr> {
match self {
Term::Mat { args: _, rules } => {
for rule in rules.iter_mut() {
rule.body.linearize_simple_matches(ctrs, lift_all_vars).unwrap();
rule.body.linearize_simple_matches(lift_all_vars).unwrap();
}
let matched_type = infer_type(rules.iter().map(|r| &r.pats[0]), ctrs)?;
match matched_type {
Type::Num | Type::Tup | Type::Any => _ = lift_match_vars(self, lift_all_vars),
Type::Adt(_) => {
lift_match_vars(self, lift_all_vars);
}
}
linearize_match_free_vars(self);
lift_match_vars(self, lift_all_vars);
}

Term::Lam { bod, .. } | Term::Chn { bod, .. } => {
bod.linearize_simple_matches(ctrs, lift_all_vars)?;
bod.linearize_simple_matches(lift_all_vars)?;
}

Term::Let { pat: Pattern::Var(..), val: fst, nxt: snd }
Expand All @@ -49,8 +42,8 @@ impl Term {
| Term::Sup { fst, snd, .. }
| Term::Opx { fst, snd, .. }
| Term::App { fun: fst, arg: snd, .. } => {
fst.linearize_simple_matches(ctrs, lift_all_vars)?;
snd.linearize_simple_matches(ctrs, lift_all_vars)?;
fst.linearize_simple_matches(lift_all_vars)?;
snd.linearize_simple_matches(lift_all_vars)?;
}

Term::Lst { .. } => unreachable!(),
Expand Down
2 changes: 1 addition & 1 deletion src/term/transform/simplify_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ fn switch_rule_submatch_arm(rule: &Rule, ctr: &Pattern, nested_fields: &[Option<
Pattern::Num(NumCtr::Succ(_, Some(var))) => vec![Pattern::Var(var.clone())],
// Similarly for the default case in a num match
Pattern::Var(var) => vec![Pattern::Var(var.clone())],
_ => rule.pats[0].children().cloned().collect::<Vec<_>>()
_ => rule.pats[0].children().cloned().collect::<Vec<_>>(),
};
if pats.is_empty() {
// We say that a unit variant always has an unused wildcard nested
Expand Down

0 comments on commit 4c8a9f9

Please sign in to comment.