Almost get cart assignments working

This commit is contained in:
Alex Bethel 2021-10-23 14:17:17 -06:00
parent 48d9d1e2e1
commit 7e0daeab29

View file

@ -254,8 +254,15 @@ impl ExecEnv {
let mut cell = self.get_var_rc(&assignable.ident)?; let mut cell = self.get_var_rc(&assignable.ident)?;
for index in indices { for index in indices {
let index = self.eval_expr(index)?; let index = self.eval_expr(index)?;
let value = cell.borrow().to_owned(); let value = cell.borrow().to_owned();
cell = Rc::clone(value.into_cart().get(&index).unwrap()); let mut value = value.into_cart();
if let Some(x) = value.get(&index) {
cell = Rc::clone(x);
} else {
cell = Rc::new(RefCell::new(Value::Cart(Default::default())));
value.insert(index, Rc::clone(&cell));
}
} }
cell.replace(value); cell.replace(value);
} }