From 5db6eebdc07ca0c720aeddc15f2b4d7e3bdd71b0 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Sat, 23 Oct 2021 14:17:17 -0600 Subject: [PATCH] Almost get cart assignments working --- ablescript/src/interpret.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ablescript/src/interpret.rs b/ablescript/src/interpret.rs index 356e9f3c..3bd8c788 100644 --- a/ablescript/src/interpret.rs +++ b/ablescript/src/interpret.rs @@ -254,8 +254,15 @@ impl ExecEnv { let mut cell = self.get_var_rc(&assignable.ident)?; for index in indices { let index = self.eval_expr(index)?; + 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); }