Skip to content

Commit 808be46

Browse files
committed
Fix[bmqeval]: Correctly store eval error code
`SimpleEvaluator::Property::evaluate` contains special logic to store evaluation error return codes in the context, using two range sentinel enumerators `ErrorType::e_EVALUATION_FIRST` and `ErrorType::e_EVALUATION_LAST`. However, as written, the condition to check whether a return code is an evaluation error code is invariably `false`. That is to say, e_EVALUATION_FIRST <= rc <= e_EVALUATION_LAST is always false, because `e_EVALUATION_FIRST = -1`, and `e_EVALUATION_LAST = -4`. Return codes grow in the negative direction, so the condition we want instead is e_EVALUATION_LAST <= rc <= e_EVALUATION_FIRST. Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
1 parent 3f51a52 commit 808be46

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ SimpleEvaluator::Property::evaluate(EvaluationContext& context) const
182182
if (value.isError()) {
183183
const int rc = value.theError().code();
184184

185-
if (ErrorType::e_EVALUATION_FIRST <= rc &&
186-
rc <= ErrorType::e_EVALUATION_LAST) {
185+
// ErrorType::e_EVALUATION_LAST and ErrorType::e_EVALUATION_FIRST are
186+
// negative, hence the flipped conditional.
187+
if (ErrorType::e_EVALUATION_LAST <= rc &&
188+
rc <= ErrorType::e_EVALUATION_FIRST) {
187189
context.setError(static_cast<ErrorType::Enum>(rc));
188190
}
189191
else {

0 commit comments

Comments
 (0)