rubysolo/dentaku

Division by Zero error in `solve` on `IF()` function not being rescued

gerardtan2018 opened this issue · 0 comments

When using the IF function, when the function is expressed this way IF(5 / 0 > 0, 100, 1000), ZeroDivisionError will be thrown due to predicate.value(context) here when trying to retrieve the dependencies.

This is not rescued by BulkExpressionSolver's with_rescued as the trigger line is in line 72 (variables_in_resolve_order) here, where the function is only trying to find_resolve_order

There was an issue in Dentaku repo that mentions the division by zero error on variable evaluation, and it might be possible that this was missed while addressing that issue, since there are 2 places where evaluation happens: 1 in the main block, the other hiding within the retrieval of dependencies of IF.

There was a commit where the short-circuit was added here which is causing the issue I am facing now. Is this short-circuit added to make the code more efficient?

Thanks you!
Gerard