Skip to content

Commit

Permalink
Fixed issue with some types incorrectly being determined to satisfy u…
Browse files Browse the repository at this point in the history
…ser-defined traits
  • Loading branch information
IsaacShelton committed Dec 18, 2024
1 parent ebeafdb commit 74f8813
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/resolved/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct CurrentConstraints {
impl CurrentConstraints {
pub fn satisfies(&self, ty: &Type, constraint: &Constraint) -> bool {
match constraint {
Constraint::PrimitiveAdd | Constraint::Trait(..) => match &ty.kind {
Constraint::PrimitiveAdd => match &ty.kind {
TypeKind::Integer(..) | TypeKind::CInteger(..) | TypeKind::Floating(..) => true,
TypeKind::Polymorph(name, constraints) => {
constraints.contains(constraint)
Expand All @@ -20,6 +20,18 @@ impl CurrentConstraints {
}
_ => false,
},
Constraint::Trait(name, _trait_ref) => match &ty.kind {
TypeKind::Polymorph(name, constraints) => {
constraints.contains(constraint)
|| self
.constraints
.get(name)
.map_or(false, |in_scope| in_scope.contains(constraint))
}
_ => {
todo!("test if user-defined trait '{}' is satisfied", name)
}
},
}
}
}
Expand Down

0 comments on commit 74f8813

Please sign in to comment.