Commit 0960e71d

0960e71d8c0fMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified

Description

Fix Float::MAX/MIN/EPSILON and Integer::MAX constant errors

Float::MAX / MIN / EPSILON / DIG / MANT_DIG compiled to undeclared C identifiers (Float_MAX etc.) because the constant-path fall-through emitted the sanitized name verbatim. Map them to the <float.h> DBL_* macros instead, and include <float.h> from sp_types.h.

Integer has no public constants in CRuby (it is arbitrary precision), so Integer::MAX / MIN must raise NameError rather than resolve. The prior code mapped Integer::MAX to INT64_MAX (a non-Ruby extension) and had no MIN arm (so Integer::MIN emitted a bare undeclared identifier). Replace both with a NameError raise, matching CRuby.

Also add the missing test/string_rpartition_regex.rb regression test for the rpartition(regex) segfault fix.

Fixes #1252 Fixes #1253

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
0960e71d8c0f
Parent
c175ffea59c1

lib/sp_types.hmodifiedView file

@@ -17,6 +17,7 @@
1717 #include <stdint.h>
1818 #include <stdbool.h>
1919 #include <stddef.h>
20+#include <float.h> /* DBL_MAX / DBL_MIN / DBL_EPSILON for Float::* constants */
2021
2122 /* mrb_int follows pointer width (decided at compile time via intptr_t):
2223 int64_t on 64-bit hosts -- PCs, no behavior change -- and int32_t on