Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[On hold] Improve undefinedidentifier processing #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fgalan
Copy link

@fgalan fgalan commented May 13, 2024

Intead of raise a UndefinedIdentifier error when a unknown identifier is found, it is replaced by null in evaluation without raising error.

The PR is still [WIP] as test has to reviwed.

Should this change be proposed into the mainstream repository (https://github.com/mozilla/jexl-rs)?

@fgalan
Copy link
Author

fgalan commented May 14, 2024

After careful examination, it is some grade of support of undefined identifiers in the upgraeam jexl-rs code. From test_undefined_identifier_truthy_ops test case.

Thus, things like this are not working:

        test("UNDEFINED", false, value!(null));
        test("UNDEFINED == 'string'", false, value!(null));
        test("'string' == UNDEFINED", false, value!(null));
        test("DEFINED ? UNDEFINED : 'WRONG'", false, value!(null));

which preclude expressions like (A==null)?'is null'|A.

But following are working:

        test("UNDEFINED ? 'WRONG' : 'RIGHT'", true, value!("RIGHT"));
        test("UNDEFINED || 'RIGHT'", true, value!("RIGHT"));
        test("'RIGHT' || UNDEFINED", true, value!("RIGHT"));

        test(
            "(UNDEFINED && UNDEFINED == 'string') || (DEFINED && DEFINED == 'string')",
            true,
            value!(true),
        );

So instead of (A==null)?'is null'|A we can use just A||'is null'.

We would leave this PR opened by the moment, but it seems we don't need this fix at the end.

@fgalan fgalan changed the title [WIP] Improve undefinedidentifier processing [On hold] Improve undefinedidentifier processing May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant