codedthinking / Kezdi.jl

An umbrella of Julia packages for data analysis, in loving memory of Gábor Kézdi
Other
9 stars 0 forks source link

Bug: Complex `@if` is not working properly. #67

Closed gergelyattilakiss closed 5 days ago

gergelyattilakiss commented 6 days ago

image

korenmiklos commented 6 days ago

Can you try with () around the expression? The error message looks like one side of the expression is BitVector, the other is Bool. It may also be the case that we need & and not &&.

korenmiklos commented 6 days ago

Both & and && should work, the only difference is that the latter short circuits: does not evaluate if the LHS is already false.

gergelyattilakiss commented 6 days ago

Wrapping in () does not solve the issue.

gergelyattilakiss commented 6 days ago

image

gergelyattilakiss commented 6 days ago

Interestingly, (... & ...) and true & true fails at parser level because it does not fit into Command structure's condition field. Connecting with && passes the parser tests so it is an expression, and sometimes it also passes the command tests too.

gergelyattilakiss commented 6 days ago

const && const and const && condition are passing. condition && condition and condition && const are not.

gergelyattilakiss commented 6 days ago

image

korenmiklos commented 6 days ago

image

Why is there an equal sign here? This should be $bitvector .| ($mask)

Note the ()

gergelyattilakiss commented 6 days ago

that was just a typo I haven't noticed. correcting the missing () too.

gergelyattilakiss commented 6 days ago

The issue is with merging boolean and vector in a boolean context like image

gergelyattilakiss commented 6 days ago

On the other hand it is very interesting that if we start with the boolean there is no error in it.

gergelyattilakiss commented 6 days ago

image

gergelyattilakiss commented 6 days ago

The soultion should be something like: image

gergelyattilakiss commented 6 days ago

The right one is || the use of .| and .& does something weird... :smile:

gergelyattilakiss commented 6 days ago

this is solved at https://github.com/codedthinking/Kezdi.jl/commit/e281d69a284088bbeb16a8a1895be2066a224dac @korenmiklos I hope this solution will not hurt when you refactor. I just changed how the && and || is parsed.

gergelyattilakiss commented 5 days ago

Refactor did not change the current test results, although I want to write some more tests to see that with proper values we get what we want

gergelyattilakiss commented 5 days ago

This goes well with the refactor added some more test cases. they pass