mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Use fresh vars for home params destructures
This commit is contained in:
parent
a1c9273721
commit
ed931a458e
1 changed files with 26 additions and 4 deletions
|
@ -6,7 +6,7 @@ use roc_can::{
|
||||||
Expr::{self, *},
|
Expr::{self, *},
|
||||||
},
|
},
|
||||||
module::ModuleParams,
|
module::ModuleParams,
|
||||||
pattern::Pattern,
|
pattern::{Pattern, RecordDestruct},
|
||||||
};
|
};
|
||||||
use roc_collections::VecMap;
|
use roc_collections::VecMap;
|
||||||
use roc_module::symbol::{IdentId, IdentIds, ModuleId, Symbol};
|
use roc_module::symbol::{IdentId, IdentIds, ModuleId, Symbol};
|
||||||
|
@ -410,11 +410,33 @@ impl<'a> LowerParams<'a> {
|
||||||
fn home_params_argument(&mut self) -> Option<(Variable, AnnotatedMark, Loc<Pattern>)> {
|
fn home_params_argument(&mut self) -> Option<(Variable, AnnotatedMark, Loc<Pattern>)> {
|
||||||
match &self.home_params {
|
match &self.home_params {
|
||||||
Some(module_params) => {
|
Some(module_params) => {
|
||||||
let new_var = self.var_store.fresh();
|
let destructs: Vec<Loc<RecordDestruct>> = module_params
|
||||||
|
.destructs
|
||||||
|
.iter()
|
||||||
|
.map(|destructure| {
|
||||||
|
destructure.map(|d| RecordDestruct {
|
||||||
|
symbol: d.symbol,
|
||||||
|
var: self.var_store.fresh(),
|
||||||
|
label: d.label.clone(),
|
||||||
|
typ: d.typ.clone(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let record_pattern = Pattern::RecordDestructure {
|
||||||
|
whole_var: module_params.record_var,
|
||||||
|
ext_var: module_params.record_ext_var,
|
||||||
|
destructs,
|
||||||
|
};
|
||||||
|
let loc_record_pattern = Loc::at(module_params.region, record_pattern);
|
||||||
|
let as_pattern =
|
||||||
|
Pattern::As(Box::new(loc_record_pattern), module_params.whole_symbol);
|
||||||
|
let loc_pattern = Loc::at(module_params.region, as_pattern);
|
||||||
|
|
||||||
Some((
|
Some((
|
||||||
new_var,
|
self.var_store.fresh(),
|
||||||
AnnotatedMark::new(self.var_store),
|
AnnotatedMark::new(self.var_store),
|
||||||
module_params.pattern(),
|
loc_pattern,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue