Skip to content

Commit

Permalink
fix: Add missing follow_bindings when checking if a type can be cas…
Browse files Browse the repository at this point in the history
…ted (#2022)

* Add missed TypeVariableCheck

* Refactor to use follow_bindings
  • Loading branch information
jfecher authored Jul 24, 2023
1 parent 5a533e7 commit 537c2bd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/noirc_frontend/src/hir/type_check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,14 @@ impl<'interner> TypeChecker<'interner> {
}

fn check_cast(&mut self, from: Type, to: Type, span: Span) -> Type {
let is_comp_time = match from {
let is_comp_time = match from.follow_bindings() {
Type::Integer(is_comp_time, ..) => is_comp_time,
Type::FieldElement(is_comp_time) => is_comp_time,
Type::PolymorphicInteger(is_comp_time, binding) => match &*binding.borrow() {
TypeBinding::Bound(from) => return self.check_cast(from.clone(), to, span),
TypeBinding::Unbound(_) => is_comp_time,
},
Type::PolymorphicInteger(is_comp_time, _) => is_comp_time,
Type::TypeVariable(_) => {
self.errors.push(TypeCheckError::TypeAnnotationsNeeded { span });
return Type::Error;
}
Type::Bool(is_comp_time) => is_comp_time,
Type::Error => return Type::Error,
from => {
Expand Down

0 comments on commit 537c2bd

Please sign in to comment.