Fixed variable parse order

This commit is contained in:
2023-06-17 22:15:58 -07:00
parent 1671bbbade
commit 41bf1954a1
3 changed files with 23 additions and 10 deletions

View File

@ -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);
}
}