Browse Source

bug fixes

pull/5/head
Jason Williams 6 years ago
parent
commit
b8b6964bc9
  1. 19
      src/lib/exec.rs
  2. 4
      src/lib/js/value.rs

19
src/lib/exec.rs

@ -200,18 +200,17 @@ impl Executor for Interpreter {
let mut matched = false; let mut matched = false;
for tup in vals.iter() { for tup in vals.iter() {
let tup: &(Expr, Vec<Expr>) = tup; let tup: &(Expr, Vec<Expr>) = tup;
match *tup { let cond = &tup.0;
(ref cond, ref block) if (val == try!(self.run(cond))) => { let block = &tup.1;
matched = true; if val == try!(self.run(cond)) {
let last_expr = block.last().unwrap(); matched = true;
for expr in block.iter() { let last_expr = block.last().unwrap();
let e_result = try!(self.run(expr)); for expr in block.iter() {
if expr == last_expr { let e_result = try!(self.run(expr));
result = e_result; if expr == last_expr {
} result = e_result;
} }
} }
_ => (),
} }
} }
if !matched && default.is_some() { if !matched && default.is_some() {

4
src/lib/js/value.rs

@ -193,10 +193,10 @@ impl ValueData {
ValueData::Function(ref func) => { ValueData::Function(ref func) => {
match *func.borrow_mut().deref_mut() { match *func.borrow_mut().deref_mut() {
Function::NativeFunc(ref mut f) => { Function::NativeFunc(ref mut f) => {
f.object.insert(field.clone(), Property::new(val)) f.object.insert(field.clone(), Property::new(val.clone()))
} }
Function::RegularFunc(ref mut f) => { Function::RegularFunc(ref mut f) => {
f.object.insert(field.clone(), Property::new(val)) f.object.insert(field.clone(), Property::new(val.clone()))
} }
}; };
} }

Loading…
Cancel
Save