Skip to content

strict_syntax ^ (XOR) and relational sides crash check_equality/check_order instead of giving feedback #307

Open

Description

@m-messer

Description of the bug

With strict_syntax: true, ^ is kept as Python XOR, which is intended. But a response or answer that uses it crashes grading, and the learner gets an EvaluationError instead of feedback.

  • check_equality: x^2 parses to a boolean (Not), and lhs_expr - rhs_expr raises TypeError: unsupported operand type(s) for -: 'Not' and 'Not'.
  • check_order (app/context/symbolic/comparison.py): it computes lhs_expr - rhs_expr with no guard. Fix TypeError when the answer or response is an inequality #297 added a guard to check_equality only, so an order criterion with a boolean or relational side fails in the same way.
  • x(x) is read as a call of a function x, so it is graded incorrect against x^2 with no explanation.

Expression(s)/input that trigger it

Response Answer Params Result
x^2 x^2 strict_syntax: true EvaluationError ('Not' - 'Not' TypeError)
x(x) x^2 strict_syntax: true incorrect, no feedback

Expected vs. actual result

  • Expected: ^ stays XOR. The response is graded incorrect, and the feedback includes NOTATION_WARNING_EXPONENT ("use ** for powers"). check_order treats a side it can't subtract as "cannot determine", as check_equality does.
  • Actual: EvaluationError.

Steps to reproduce / where it was used

evaluation_function("x^2", "x^2", {"strict_syntax": True}). Same result on pre-refactor main, on main, and on the stack top.


Jira: LAM-292

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions