Skip to content

Commit

Permalink
fix(compiler): Don't panic when matching a tuple against an alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Jun 9, 2019
1 parent 45427d5 commit 777bd31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/pattern_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,17 @@ match (Some 10, 1) with
"#,
10
}

test_expr! {
pattern_match_tuple_alias,
r#"
type MyType = (String, Int)
let getName thing : MyType -> String =
let (name, count) = thing
name
getName ("abc", 123)
"#,
"abc".to_string()
}
2 changes: 2 additions & 0 deletions vm/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,8 @@ impl<'a, 'e> PatternTranslator<'a, 'e> {
}
}
ast::Pattern::Tuple { ref typ, ref elems } => {
let typ = remove_aliases_cow(&self.0.env, &mut NullInterner, typ);

for (i, (elem, field_type)) in elems.iter().zip(typ.row_iter()).enumerate() {
if !add_duplicate_ident(
&mut replacements,
Expand Down

0 comments on commit 777bd31

Please sign in to comment.