feat: add support for assign and nested assign
My formatter is not working :'(
This commit is contained in:
parent
e7a61df1f3
commit
d1ca85c4bc
|
@ -1058,7 +1058,11 @@ pub fn check_when_pattern_needs(
|
||||||
Pattern::Discard { .. } => {
|
Pattern::Discard { .. } => {
|
||||||
*clause_properties.needs_constr_var() = true;
|
*clause_properties.needs_constr_var() = true;
|
||||||
}
|
}
|
||||||
_ => todo!("{pattern:#?}"),
|
Pattern::Assign { pattern, .. } => {
|
||||||
|
*clause_properties.needs_constr_var() = true;
|
||||||
|
|
||||||
|
check_when_pattern_needs(pattern, clause_properties)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1574,7 +1574,19 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
Some(item_name)
|
Some(item_name)
|
||||||
}
|
}
|
||||||
Pattern::Assign { .. } => todo!("Nested assign is not yet done"),
|
Pattern::Assign { name, pattern, .. } => {
|
||||||
|
|
||||||
|
|
||||||
|
let inner_name = self.nested_pattern_ir_and_label(pattern, pattern_vec, pattern_type, scope.clone(), final_clause);
|
||||||
|
|
||||||
|
pattern_vec.push(Air::Let { scope: scope.clone(), name: name.clone() });
|
||||||
|
|
||||||
|
pattern_vec.push(Air::Var { scope, constructor: ValueConstructor::public(pattern_type.clone(), ValueConstructorVariant::LocalVariable { location: Span::empty() }), name: inner_name.clone().unwrap(), variant_name: String::new() });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inner_name
|
||||||
|
}
|
||||||
Pattern::Int { .. } => todo!("Nested pattern-match on integers isn't implemented yet. Use when clause-guard as an alternative, or break down the pattern."),
|
Pattern::Int { .. } => todo!("Nested pattern-match on integers isn't implemented yet. Use when clause-guard as an alternative, or break down the pattern."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue