diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 0940857c..60732b8b 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -1169,8 +1169,10 @@ impl TypedClause { } } - pub fn find_node(&self, byte_index: usize) -> Option> { - self.then.find_node(byte_index) + pub fn find_node(&self, byte_index: usize, subject_type: &Rc) -> Option> { + self.pattern + .find_node(byte_index, subject_type) + .or_else(|| self.then.find_node(byte_index)) } } diff --git a/crates/aiken-lang/src/expr.rs b/crates/aiken-lang/src/expr.rs index dce523c5..65f7480c 100644 --- a/crates/aiken-lang/src/expr.rs +++ b/crates/aiken-lang/src/expr.rs @@ -378,7 +378,7 @@ impl TypedExpr { .or_else(|| { clauses .iter() - .find_map(|clause| clause.find_node(byte_index)) + .find_map(|clause| clause.find_node(byte_index, &subject.tipo())) }) .or(Some(Located::Expression(self))),