-
Notifications
You must be signed in to change notification settings - Fork 155
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
fix: correct inconsistent runtime typing for logicalVectorEvaluator
#5160
Conversation
f84f478
to
55573a8
Compare
(r) => { | ||
return {x: (if r:{#O with a: v[bool], b: v[bool], x: v[#K], y: v[#K]}.a:v[bool] and:bool r:{#O with a: v[bool], b: v[bool], x: v[#K], y: v[#K]}.b:v[bool] then r:{#O with a: v[bool], b: v[bool], x: v[#K], y: v[#K]}.x:v[#K] else r:{#O with a: v[bool], b: v[bool], x: v[#K], y: v[#K]}.y:v[#K]):v[#G]}:{x: v[#G]} | ||
}:(r: {#O with a: v[bool], b: v[bool], x: v[#K], y: v[#K]}) => {x: v[#G]}"##]].assert_eq(&crate::semantic::formatter::format_node( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing for the logical and conditional exprs here on the rust side look good. The runtime doesn't appear to rely on this info in this case, it seems.
// Using a logical expr in the test of the conditional expr produced a | ||
// runtime error: | ||
// ``` | ||
// cannot use test of type vector in conditional expression; expected boolean | ||
// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, I think we might have seen this for any nested expression where logical ops were children of a larger expression. I'm trying to think of why we didn't see this in the test suite earlier...
When a logical op appears in the `test` position for a conditional, we see: ``` cannot use test of type vector in conditional expression; expected boolean ``` The runtime typing for `logicalVectorEvaluator` was bool rather than a vector of bool which would cause the conditional evaluator to incorrectly select the non-vectorized implementation (it expects test, consequent and alternate to all be vectors in order to use the vectorized version). By updating the `Type()` method for `logicalVectorEvaluator` to be a vector of bool, the `conditionalVectorEvaluator` is able to be used.
55573a8
to
2e4f4ec
Compare
logicalVectorEvaluator
* test: vectorized nested logical ops This is mostly just to check for regressions (the fix was already made in #5160). Prior to the fix in #5160, this test would fail with: ``` runtime error: cannot use operand of type vector with logical or; expected boolean ``` Today, the test passes and all is well. * chore: make generate
Fixes #5155
...which shows a runtime error when nesting a logical expression inside a conditional expression.
When in the
test
position, we'd get:Originally,
logicalVectorEvaluator
advertised a runtime type of bool, which is inconsistent with reality since it is actually a vector of bool.The error message we saw in this situation stemmed from the fact we choose either the vectorized or row-based conditional evaluator with this check here:
flux/compiler/compiler.go
Lines 657 to 669 in df2b4c4
Since
test
in this case was alogicalVectorEvaluator
with incorrect (bool) typing, this check failed and we fall back to the non-vectorized version for conditional.This is why the error message states "expected boolean" -- we were calling the non-vectorized version with a vector as input.
This diff updates the impl for
logicalVectorEvaluator.Type()
such that it reports a vector of bool instead of bool.Checklist
Dear Author 👋, the following checks should be completed (or explicitly dismissed) before merging.
experimental/
N/Adocs/Spec.md
has been updated N/ADear Reviewer(s) 👋, you are responsible (among others) for ensuring the completeness and quality of the above before approval.