From d078bc11b7142e672429c787f7d4448f682f63df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Bria=C5=84ski?= Date: Mon, 18 Nov 2024 10:04:50 +0100 Subject: [PATCH] Fix type casting with mixed arguments in randint --- pkg/eval/builtin_fn_num.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/eval/builtin_fn_num.go b/pkg/eval/builtin_fn_num.go index d9fefe9c5..83d37942c 100644 --- a/pkg/eval/builtin_fn_num.go +++ b/pkg/eval/builtin_fn_num.go @@ -375,7 +375,15 @@ func randint(args ...vals.Num) (vals.Num, error) { if len(args) == 1 { low, high = big.NewInt(0), args[0].(*big.Int) } else { - low, high = args[0].(*big.Int), args[1].(*big.Int) + var casted_args [2]*big.Int + for i, arg := range args { + if casted_arg, ok := arg.(*big.Int); ok { + casted_args[i] = casted_arg + } else { + casted_args[i] = big.NewInt(int64(arg.(int))) + } + } + low, high = casted_args[0], casted_args[1] } if high.Cmp(low) <= 0 { return 0, errs.BadValue{What: "high value",