fix(check): collapse_links on tuple_index access closes #905

This commit is contained in:
rvcas 2024-04-02 19:45:16 -04:00
parent 7c5b9aa35e
commit b27fcf38e5
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
2 changed files with 22 additions and 1 deletions

View File

@ -2274,3 +2274,24 @@ fn validator_private_everything() {
assert!(check_validator(parse(source_code)).is_ok()) 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<a>, 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())
}

View File

@ -2045,7 +2045,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
) -> Result<TypedExpr, Error> { ) -> Result<TypedExpr, Error> {
let tuple = self.infer(tuple)?; let tuple = self.infer(tuple)?;
let tipo = match *tuple.tipo() { let tipo = match *collapse_links(tuple.tipo()) {
Type::Tuple { Type::Tuple {
ref elems, ref elems,
alias: _, alias: _,