diff --git a/crates/aiken-lang/src/tests/check.rs b/crates/aiken-lang/src/tests/check.rs index 865f83f0..a188efc4 100644 --- a/crates/aiken-lang/src/tests/check.rs +++ b/crates/aiken-lang/src/tests/check.rs @@ -2274,3 +2274,24 @@ fn validator_private_everything() { assert!(check_validator(parse(source_code)).is_ok()) } + +#[test] +fn tuple_access_on_call() { + let source_code = r#" + use aiken/builtin + + pub fn list_at(xs: List, index: Int) -> a { + if index == 0 { + builtin.head_list(xs) + } else { + list_at(builtin.tail_list(xs), index - 1) + } + } + + fn foo() { + [list_at([(1, 2)], 0).2nd, ..[1, 2]] + } + "#; + + assert!(check(parse(source_code)).is_ok()) +} diff --git a/crates/aiken-lang/src/tipo/expr.rs b/crates/aiken-lang/src/tipo/expr.rs index 8875506a..7aa932f9 100644 --- a/crates/aiken-lang/src/tipo/expr.rs +++ b/crates/aiken-lang/src/tipo/expr.rs @@ -2045,7 +2045,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> { ) -> Result { let tuple = self.infer(tuple)?; - let tipo = match *tuple.tipo() { + let tipo = match *collapse_links(tuple.tipo()) { Type::Tuple { ref elems, alias: _,