From f1d7bdaa5a85cbba913495deb8f22c29ef0bca3e Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sat, 24 Feb 2024 21:31:39 +0900 Subject: [PATCH] Accept floats in things that use krk_long_to_int --- src/obj_long.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/obj_long.c b/src/obj_long.c index cd31d143..48d1594d 100644 --- a/src/obj_long.c +++ b/src/obj_long.c @@ -2382,6 +2382,13 @@ int krk_long_to_int(KrkValue val, char size, void * out) { accum ^= 0xFFFFffffFFFFffff; } } +#ifndef KRK_NO_FLOAT + } else if (IS_FLOATING(val)) { + krk_push(krk_int_from_float(AS_FLOATING(val))); + int res = krk_long_to_int(krk_peek(0), size, out); + krk_pop(); + return res; +#endif } else { krk_runtimeError(vm.exceptions->typeError, "expected %s, not '%T'", "int", val); return 0;