Skip to content

Commit

Permalink
Evaluate expression with non-exec grounded atom on the first position
Browse files Browse the repository at this point in the history
  • Loading branch information
vsbogd committed Mar 6, 2025
1 parent 2ee05be commit 27dc35f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/metta/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ fn eval_impl<'a, T: Space>(to_eval: Atom, space: T, bindings: Bindings, prev: Op
match atom_as_slice(&to_eval) {
Some([Atom::Grounded(op), args @ ..]) => {
match op.as_grounded().as_execute() {
None => finished_result(return_not_reducible(), bindings, prev),
None => query(space, prev, to_eval, bindings, vars),
Some(executable) => {
let exec_res = executable.execute(args);
log::debug!("eval: execution results: {:?}", exec_res);
Expand Down Expand Up @@ -1559,6 +1559,14 @@ mod tests {
assert_eq!(result, vec![NOT_REDUCIBLE_SYMBOL]);
}

#[test]
fn interpret_atom_evaluate_non_executable_grounded_atom_on_a_first_position() {
let space = space("(= ($x > $y) (> $x $y))");

let result = call_interpret(space, &expr!("eval" ({1} ">" {2})));
assert_eq!(result, vec![expr!(">" {1} {2})]);
}


#[test]
fn interpret_atom_chain_incorrect_args() {
Expand Down

0 comments on commit 27dc35f

Please sign in to comment.