mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
start of destructure patterns
This commit is contained in:
parent
94267cf7ab
commit
e81daf25cb
4 changed files with 54 additions and 3 deletions
|
@ -2047,6 +2047,34 @@ impl Declarations {
|
|||
index
|
||||
}
|
||||
|
||||
/// Any def with a weird pattern
|
||||
pub fn push_destructure_def(
|
||||
&mut self,
|
||||
loc_pattern: Loc<Pattern>,
|
||||
loc_expr: Loc<Expr>,
|
||||
expr_var: Variable,
|
||||
annotation: Option<Annotation>,
|
||||
pattern_vars: VecMap<Symbol, Variable>,
|
||||
) -> usize {
|
||||
let index = self.declarations.len();
|
||||
|
||||
let destruct_def = DestructureDef {
|
||||
loc_pattern,
|
||||
pattern_vars,
|
||||
};
|
||||
|
||||
let destructure_def_index = Index::push_new(&mut self.destructs, destruct_def);
|
||||
|
||||
self.declarations.push(DeclarationTag::Destructure(destructure_def_index));
|
||||
self.variables.push(expr_var);
|
||||
self.symbols.push(Loc::at_zero(Symbol::ATTR_ATTR));
|
||||
self.annotations.push(annotation);
|
||||
|
||||
self.expressions.push(loc_expr);
|
||||
|
||||
index
|
||||
}
|
||||
|
||||
pub fn push_def(&mut self, def: Def) {
|
||||
match def.loc_pattern.value {
|
||||
Pattern::Identifier(symbol) => match def.loc_expr.value {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue