From 1e7c0fcc9ad9f6212752b0fce54d502a5eb6459c Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Thu, 14 Mar 2024 20:53:24 -0400 Subject: [PATCH] [PRISM] Fix float in case dispatch --- prism_compile.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/prism_compile.c b/prism_compile.c index 92ebfaeb43bcd7..87d5ed450bfc82 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -4167,8 +4167,17 @@ pm_compile_case_node_dispatch(VALUE dispatch, const pm_node_t *node, LABEL *labe VALUE key = Qundef; switch (PM_NODE_TYPE(node)) { + case PM_FLOAT_NODE: { + key = pm_static_literal_value(node, scope_node); + double intptr; + + if (modf(RFLOAT_VALUE(key), &intptr) == 0.0) { + key = (FIXABLE(intptr) ? LONG2FIX((long) intptr) : rb_dbl2big(intptr)); + } + + break; + } case PM_FALSE_NODE: - case PM_FLOAT_NODE: case PM_INTEGER_NODE: case PM_NIL_NODE: case PM_SOURCE_FILE_NODE: