gitgabrio commented on code in PR #5761:
URL:
https://github.com/apache/incubator-kie-drools/pull/5761#discussion_r1512647550
##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/expressiontyper/ExpressionTyper.java:
##########
@@ -224,16 +225,19 @@ private Optional<TypedExpression>
toTypedExpressionRec(Expression drlxExpr) {
TypedExpression left = optLeft.get();
TypedExpression right = optRight.get();
- ArithmeticCoercedExpression.ArithmeticCoercedExpressionResult
coerced;
- try {
- coerced = new ArithmeticCoercedExpression(left, right,
operator).coerce();
- } catch
(ArithmeticCoercedExpression.ArithmeticCoercedExpressionException e) {
- logger.error("Failed to coerce : {}",
e.getInvalidExpressionErrorResult());
- return empty();
- }
+ // Can be a binary expression of non-numeric types, like String +
customType, etc.
+ if (ClassUtils.isNumericClass(left.getRawClass()) ||
ClassUtils.isNumericClass(right.getRawClass())) {
Review Comment:
Yes, but `ArithmeticCoercionExpression` should be returned only with
number/string elements; otherwise, a different expression is needed.
With the above, when one of the element is a number and the other is not a
number nor a string, the code will throw an exception and return an empty
Optional.
Instead, when one element is number and the other is not a number nor a
string, I think it should anyway return a BynaryExpr (as at line 242).
Is that clear ? Does this make sense ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]