mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
handle Suffixed in first index
This commit is contained in:
parent
d6a01b3014
commit
c4b459b436
3 changed files with 37 additions and 5 deletions
|
@ -219,8 +219,6 @@ fn desugar_defs_node_suffixed<'a>(
|
|||
// Remove the suffixed def
|
||||
copied_defs.remove_value_def(tag_index);
|
||||
|
||||
dbg!(&copied_defs);
|
||||
|
||||
// Recurse using new Defs to get new expression
|
||||
let new_loc_expr = desugar_defs_node_suffixed(
|
||||
arena,
|
||||
|
@ -501,7 +499,6 @@ pub fn desugar_expr<'a>(
|
|||
module_path,
|
||||
),
|
||||
Defs(defs, loc_ret) => {
|
||||
|
||||
let mut defs = (*defs).clone();
|
||||
desugar_defs_node_values(arena, &mut defs, src, line_info, module_path);
|
||||
let loc_ret = desugar_expr(arena, loc_ret, src, line_info, module_path);
|
||||
|
|
|
@ -184,4 +184,10 @@ impl<T, U> EitherIndex<T, U> {
|
|||
Err(Index::new(self.index ^ Self::MASK))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn decrement_index(&mut self) {
|
||||
if self.index > 0 {
|
||||
self.index -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,6 +494,7 @@ impl<'a> Defs<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
// TODO QUESTION DO WE NEED TO REMOVE ANYTHING FROM SPACES FIELD?
|
||||
pub fn remove_value_def(&mut self, index: usize) {
|
||||
match self
|
||||
.tags
|
||||
|
@ -502,10 +503,38 @@ impl<'a> Defs<'a> {
|
|||
.split()
|
||||
{
|
||||
Ok(type_index) => {
|
||||
self.type_defs.remove(type_index.index());
|
||||
|
||||
let index = type_index.index();
|
||||
|
||||
// remove from vec
|
||||
self.type_defs.remove(index);
|
||||
|
||||
// update all of the remaining indexes in type_defs
|
||||
for (tag_index, tag) in self.tags.iter_mut().enumerate() {
|
||||
|
||||
// only update later indexes into type_defs
|
||||
if tag_index > index && tag.split().is_ok() {
|
||||
tag.decrement_index();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Err(value_index) => {
|
||||
self.value_defs.remove(value_index.index());
|
||||
|
||||
let index: usize = value_index.index();
|
||||
|
||||
// remove from vec
|
||||
self.value_defs.remove(index);
|
||||
|
||||
// update all of the remaining indexes in value_defs
|
||||
for (tag_index, tag) in self.tags.iter_mut().enumerate() {
|
||||
|
||||
// only update later indexes into value_defs
|
||||
if tag_index > index && tag.split().is_err() {
|
||||
tag.decrement_index();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
self.tags.remove(index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue