Skip to content

Commit

Permalink
Add the add_constraint function
Browse files Browse the repository at this point in the history
  • Loading branch information
purefunctor committed Feb 15, 2024
1 parent 6cfae65 commit c1ca219
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion crates/analyzer-module/src/infer/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
id::InFile, infer::pretty_print, scope::ResolveInfo, surface::tree::*, InferenceDatabase,
};

use super::{CoreType, CoreTypeId, Hint, InferenceResult};
use super::{Constraint, CoreType, CoreTypeId, Hint, InferenceResult};

use recursive::{recursive_data_groups, recursive_let_names, recursive_value_groups};

Expand Down Expand Up @@ -58,6 +58,10 @@ impl<'a> InferContext<'a> {
fn current_hints(&self) -> Arc<[Hint]> {
Arc::from(self.state.hints.as_slice())
}

fn add_constraint(&mut self, constraint: Constraint) {
self.result.constraints.push(constraint)
}
}

type UnificationDeferred = (Arc<[Hint]>, InFile<u32>, InFile<u32>);
Expand Down
6 changes: 3 additions & 3 deletions crates/analyzer-module/src/infer/rules/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ impl InferContext<'_> {
}
(CoreType::Unification(x_u), CoreType::Unification(y_u)) => {
if x_u != y_u {
self.result.constraints.push(Constraint::UnifyDeep(hints, x_u, y_u));
self.add_constraint(Constraint::UnifyDeep(hints, x_u, y_u));
}
}
(CoreType::Unification(x_u), _) => {
self.result.constraints.push(Constraint::UnifySolve(hints, x_u, y_id));
self.add_constraint(Constraint::UnifySolve(hints, x_u, y_id));
}
(_, CoreType::Unification(y_u)) => {
self.result.constraints.push(Constraint::UnifySolve(hints, y_u, x_id));
self.add_constraint(Constraint::UnifySolve(hints, y_u, x_id));
}
(CoreType::Constructor(x_c), CoreType::Constructor(y_c)) => if x_c != y_c {},
(CoreType::Primitive(x_p), CoreType::Primitive(y_p)) => {
Expand Down

0 comments on commit c1ca219

Please sign in to comment.