I've noticed by accident that JSONata mutates the variable passed to the evaluate method call, if evaluation fails due to an error associated with that variable, here's the reproduction branch: #589
it("should not mutate bound variable on failure", function() {
var expr = jsonata("$myVariable()");
var myVariable = { "foo": "bar" };
try {
expr.evaluate(testdata2, { myVariable });
} catch (e) {
// ignore the evaluation error
}
expect(myVariable).to.deep.equal({ "foo": "bar" });
});

I've noticed by accident that JSONata mutates the variable passed to the
evaluatemethod call, if evaluation fails due to an error associated with that variable, here's the reproduction branch: #589