From 6849f7f2961d0029b03d3b6ba9559fc870f4d262 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Fri, 5 Nov 2021 16:18:07 -0600 Subject: [PATCH] Coerce indexing assignments into non-carts --- ablescript/src/interpret.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ablescript/src/interpret.rs b/ablescript/src/interpret.rs index d7db46b..8ea0472 100644 --- a/ablescript/src/interpret.rs +++ b/ablescript/src/interpret.rs @@ -11,6 +11,7 @@ use std::{ cell::RefCell, collections::{HashMap, VecDeque}, io::{stdin, stdout, Read, Write}, + mem::swap, ops::Range, process::exit, rc::Rc, @@ -266,7 +267,18 @@ impl ExecEnv { c.insert(index, Rc::clone(&next_cell)); } } - _ => todo!(), + x => { + // Annoying borrow checker dance + // to move *x. + let mut tmp = Value::Nul; + swap(&mut tmp, x); + + let mut c = tmp.into_cart(); + next_cell = + Rc::new(RefCell::new(Value::Cart(Default::default()))); + c.insert(index, Rc::clone(&next_cell)); + *x = Value::Cart(c); + } } cell = next_cell; }