Implement tuple pattern parsing

Step 2 of N in implementing #4465
This commit is contained in:
Joshua Warner 2022-11-11 14:18:53 -05:00
parent 5f74e10d32
commit ca5d084497
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
17 changed files with 369 additions and 25 deletions

View file

@ -1852,9 +1852,15 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
Ok(Pattern::RecordDestructure(patterns))
}
Expr::Tuple(_fields) => {
todo!("tuple patterns")
}
Expr::Tuple(fields) => Ok(Pattern::Tuple(fields.map_items_result(
arena,
|loc_expr| {
Ok(Loc {
region: loc_expr.region,
value: expr_to_pattern_help(arena, &loc_expr.value)?,
})
},
)?)),
&Expr::Float(string) => Ok(Pattern::FloatLiteral(string)),
&Expr::Num(string) => Ok(Pattern::NumLiteral(string)),