mirror of
https://github.com/rm-dr/daisy
synced 2025-08-24 04:05:29 -07:00
Fixed variable parse order
This commit is contained in:
@ -59,14 +59,16 @@ pub fn evaluate(t: &Expression, context: &mut Context) -> Result<Expression, Eva
|
||||
|
||||
} else {
|
||||
// Move down the tree
|
||||
coords.push(0);
|
||||
|
||||
let n = root.get_at_coords(&coords[..]);
|
||||
if let Some(n) = n {
|
||||
if let Expression::Operator(Operator::Define, _) = n {
|
||||
// Don't evaluate the first argument of a define.
|
||||
// This prevents variables from being expanded before a re-assignment.
|
||||
if let Expression::Operator(Operator::Define, _) = g {
|
||||
*coords.last_mut().unwrap() += 1;
|
||||
coords.push(0);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
coords.push(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,8 @@ pub fn eval_operator(op: &Operator, args: &VecDeque<Expression>, context: &mut C
|
||||
let b = &args[1];
|
||||
|
||||
if let Expression::Variable(s) = &args[0] {
|
||||
context.push_var(s.clone(), b.clone());
|
||||
let r = context.push_var(s.clone(), b.clone());
|
||||
if r.is_err() { return Err(EvalError::BadDefineName); }
|
||||
return Ok(Some(b.clone()));
|
||||
} else { return Err(EvalError::BadDefineName); }
|
||||
},
|
||||
|
Reference in New Issue
Block a user