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

Inconsistency between null and undefined operations #133

Open
mapedraza opened this issue Sep 12, 2023 · 1 comment
Open

Inconsistency between null and undefined operations #133

mapedraza opened this issue Sep 12, 2023 · 1 comment

Comments

@mapedraza
Copy link

After debugging some issues found in telefonicaid/iotagent-node-lib#1440 we faced that the Library behaviour when facing null and undefined variables (or constants) in expressions is not so consistent. After that, we made some tests that con can check in the following JEXL Playground

In which the following expressions are defined:

{
t0n:null,
t0u:undefined,
t1n:n,
t1u:u,
t2n:n==null,
t2u:u==null,
t3n:n==undefined,
t3u:u==undefined,
t4n:null*2,
t4u:undefined*2,
t5n:n*2,
t5u:u*2,
t6n:null+2,
t6u:undefined+2,
t7n:n+2,
t7u:u+2,
t8n:n*2==null,
t8u:u*2==null,
t9n:n*2==undefined,
t9u:u*2==undefined
}

And the following output is returned:

{
  "t1n": null,
  "t2n": true,
  "t2u": true,
  "t3n": true,
  "t3u": true,
  "t4n": null,
  "t4u": null,
  "t5n": 0,
  "t5u": null,
  "t6n": null,
  "t6u": null,
  "t7n": 2,
  "t7u": null,
  "t8n": false,
  "t8u": false,
  "t9n": false,
  "t9u": false
}

Note that n:null and u is not defined (undefined)

It is specially meaningful cases like t5n that is 0 and t5u that is not appearing (undefined) or t4n vs t8n.

The expected behaviour is, that any arithmetic operation involving null or undefined return that value (or null, or undefined), being aligned when using null and undefined constants

@mapedraza
Copy link
Author

Maybe related: #65

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

No branches or pull requests

1 participant