Skip to content

[bug] JSONata mutates bindings passed as arguments during evaluate call #590

Open
@asennikov

Description

@asennikov

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

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions