Skip to content

Commit

Permalink
chore: small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Feb 27, 2024
1 parent 48230c8 commit a92fd10
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions compiler/noirc_frontend/src/hir/type_check/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,14 @@ impl<'interner> TypeChecker<'interner> {
let expr_span = self.interner.expr_span(&stmt.0);

// Must type check the assertion message expression so that we instantiate bindings
// We always allow unsafe calls for assert messages as these may be a dynamic assert message call.
let old_allow_unsafe = self.allow_unsafe;
self.allow_unsafe = true;
stmt.2.map(|assert_msg_expr| self.check_expression(&assert_msg_expr));
self.allow_unsafe = old_allow_unsafe;
if let Some(assert_msg_expr) = stmt.2 {
// We always allow unsafe calls for assert messages as these may be a dynamic assert message call.
// We then must restore the original value however.
let old_allow_unsafe = self.allow_unsafe;
self.allow_unsafe = true;
self.check_expression(&assert_msg_expr);
self.allow_unsafe = old_allow_unsafe;
};

self.unify(&expr_type, &Type::Bool, || TypeCheckError::TypeMismatch {
expr_typ: expr_type.to_string(),
Expand Down

0 comments on commit a92fd10

Please sign in to comment.