From 9127dcdd6eea58bd96e52cadda06e87b1b3cbd90 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Wed, 13 Mar 2024 13:25:51 +0100 Subject: [PATCH] Add note on the type-casting check. --- crates/aiken-lang/src/tipo/expr.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/aiken-lang/src/tipo/expr.rs b/crates/aiken-lang/src/tipo/expr.rs index 6b4694ae..459ae756 100644 --- a/crates/aiken-lang/src/tipo/expr.rs +++ b/crates/aiken-lang/src/tipo/expr.rs @@ -968,10 +968,6 @@ impl<'a, 'b> ExprTyper<'a, 'b> { None }; - if kind.is_expect() && value_typ.is_or_holds_opaque() { - return Err(Error::ExpectOnOpaqueType { location }); - } - // Ensure the pattern matches the type of the value let pattern = PatternTyper::new(self.environment, &self.hydrator).unify( untyped_pattern.clone(), @@ -980,6 +976,14 @@ impl<'a, 'b> ExprTyper<'a, 'b> { kind.is_let(), )?; + // FIXME: This check is insufficient as we need to also assert the type + // definition itself since there might be nested opaque types on the rhs. + // + // For that, we must lookup + if kind.is_expect() && value_typ.is_or_holds_opaque() { + return Err(Error::ExpectOnOpaqueType { location }); + } + // If `expect` is explicitly used, we still check exhaustiveness but instead of returning an // error we emit a warning which explains that using `expect` is unnecessary. match kind {