summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-03-14 20:53:24 -0400
committerKevin Newton <[email protected]>2024-03-14 21:59:26 -0400
commit1e7c0fcc9ad9f6212752b0fce54d502a5eb6459c (patch)
treef0583fc787ce78099429472973ddddd5cc7ff8f9
parent3fcab3cddf2e796a3e3b9fd8b308fd351126e305 (diff)
[PRISM] Fix float in case dispatch
-rw-r--r--prism_compile.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/prism_compile.c b/prism_compile.c
index 92ebfaeb43..87d5ed450b 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: