JEXL in Rust
Releases are done using cargo release
. Check cargo-release for more information
This project is licensed under the Mozilla Public License 2.0
JEXL in Rust
License: Mozilla Public License 2.0
JEXL in Rust
Releases are done using cargo release
. Check cargo-release for more information
This project is licensed under the Mozilla Public License 2.0
Trying to evaluate "a" != "b"
:
Invalid binary operation, left: "a", right: "b", operation: Not equal
I found an error "UnrecognizedToken { token: (8, Token(14, "-"), 9)"
ex. : let rs = eval.eval("{a: -3}")?;
and no error if: let rs = eval.eval("{a: 0-3}")?;
please fix this.
Currently, attributes not defined in the context are interpreted as null
.
Prior to version 0.2.0, null
was not supported in any binary operations.
This meant that expressions with missing attribute errored: not because the attribute was missing, but because binary operations on null
were not supported.
Missing attributes can come from:
We'd like expression authors to be able detect the absence of an attribute in their expressions:
e.g.
attr_v2 ? attr_v2 == 'value' : attr == 'value'
attr_v2 && attr_v2 == 'value'
This issue is to make undefined
attributes error, BUT make is_truthy
for undefined return false
.
We need to make sure our implementation isn't missing anything large,
We'll need to add some complex tests that capture a use case (a targeting
field of a nimbus experiment is a good candidate)
Do a comparison against https://github.com/mozilla/mozjexl/blob/master/test/evaluator/Evaluator.js to ensure we are covering all test cases.
I have a feeling we'll need to do some reordering of the expressions in the .lalrpop
file once we test against a complex example
Similar to #15, binary expressions with boolean values are not available. AND and OR are supported, but
==
!=
XOR
…and others are missing.
Without a boolean comparison (==
) or NOT (!
) this makes boolean context values much less useful.
There are a few unwrap
s in the code base that should be errors instead
Additionally the lifetime stuation with the errors is a little annoying
Probably will have two prs here, a mandatory replacement of the unwrap
s and an overall cleanup.
There are a bunch of failing test with #[should_panic]
We should fix those
Trying to evaluate var == null
when var
is not defined in the context leads to the following error result value:
Invalid binary operation, left: null, right: null, operation: Equal
Any use of !
in an expression (see mozjexl) leads to a parse error.
A couple of pieces here
eval
functions of the Evaluator
.lalrpop
file, for future maintainablilityWe need to support custom transforms for things like versionCompare
.
Line 342 in 1eb23a9
Ref: https://github.com/mozilla/mozjexl#transforms
Ref: https://searchfox.org/mozilla-central/source/toolkit/components/utils/FilterExpressions.jsm
Consider the following:
let evaluator = Evaluator::new();
let context = value!({
"foo": null,
});
let expr = "foo".to_string();
let r = evaluator.eval_in_context(&expr, context).unwrap();
In the above snippet, foo
will evaluate to null
. This is the same behavior that is seen in jexl. If we expand this to an equality test, however, you will see that the binary comparison is not currently possible:
...
let expr = "foo == null".to_string();
let r = evaluator.eval_in_context(&expr, context).unwrap();
This will produce the following error:
thread '...' panicked at 'called `Result::unwrap()` on an `Err` value: UndefinedIdentifier("null")', jexl-eval/src/lib.rs:816:59
Equality comparisons should allow for null
identifiers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.