From 48098f83c1e3943d1fb76aaecdce3b4f56cf4d4a Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 17 Apr 2021 08:28:24 +0200 Subject: feat(grfn/achilles): Implement tuples, and tuple patterns Implement tuple expressions, types, and patterns, all the way through the parser down to the typechecker. In LLVM, these are implemented as anonymous structs, using an `extract` instruction when they're pattern matched on to get out the individual fields. Currently the only limitation here is patterns aren't supported in function argument position, but you can still do something like fn xy = let (x, y) = xy in x + y Change-Id: I357f17e9d4052e741eda8605b6662822f331efde Reviewed-on: https://cl.tvl.fyi/c/depot/+/3027 Reviewed-by: grfn Tested-by: BuildkiteCI --- users/grfn/achilles/src/passes/hir/strip_positive_units.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'users/grfn/achilles/src/passes/hir/strip_positive_units.rs') diff --git a/users/grfn/achilles/src/passes/hir/strip_positive_units.rs b/users/grfn/achilles/src/passes/hir/strip_positive_units.rs index 91b56551c82d..85ee1cce4859 100644 --- a/users/grfn/achilles/src/passes/hir/strip_positive_units.rs +++ b/users/grfn/achilles/src/passes/hir/strip_positive_units.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::mem; -use ast::hir::Binding; +use ast::hir::{Binding, Pattern}; use ast::Literal; use void::{ResultVoidExt, Void}; @@ -42,8 +42,10 @@ impl<'a, 'ast> Visitor<'a, 'ast, ast::Type<'ast>> for StripPositiveUnits { bindings: extracted .into_iter() .map(|expr| Binding { - ident: Ident::from_str_unchecked("___discarded"), - type_: expr.type_().clone(), + pat: Pattern::Id( + Ident::from_str_unchecked("___discarded"), + expr.type_().clone(), + ), body: expr, }) .collect(), -- cgit 1.4.1