Skip to content

Commit

Permalink
Coerce the return value from functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Jul 3, 2023
1 parent 771f0f1 commit d26c2a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rule_engine/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ def evaluate(self, thing):
raise error
except Exception as error:
raise errors.FunctionCallError('function call failed', error=error, function_name=function_name) from None
return result
return self._new_value(result)

def _validate_function(self, function_type, arguments):
if not isinstance(function_type, DataType.FUNCTION.__class__):
Expand Down
4 changes: 2 additions & 2 deletions lib/rule_engine/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def _builtin_random(boundary=None):
if boundary:
if not types.is_natural_number(boundary):
raise errors.FunctionCallError('argument #1 (boundary) must be a natural number')
return decimal.Decimal(random.randint(0, int(boundary)))
return decimal.Decimal(random.random())
return random.randint(0, int(boundary))
return random.random()

def _builtins_split(string, sep=None, maxsplit=None):
if maxsplit is None:
Expand Down

0 comments on commit d26c2a2

Please sign in to comment.