diff options
author | nagachika <nagachika@ruby-lang.org> | 2020-07-19 12:16:37 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2020-07-19 12:16:37 +0900 |
commit | d24cce8e7f48b0b45f726f5f1ac7ff796f46ba72 (patch) | |
tree | 5a67996530467f025a19091036980d293277d356 /version.h | |
parent | f43b8c4f7304ebea91cd01d5606e13273d0fd755 (diff) |
merge revision(s) bf1a6771f305ea286a3ae575676924551c03e857,c1463625555b061a2b94c3b6c5581730b482a285: [Backport #17012] [Backport #17014]
Fix non-numeric exclusive Range#minmax bug
The implementation of Range#minmax added in d5c60214c45 causes the
following incorrect behaviour:
('a'...'c').minmax => ["a", ["a", "b"]]
instead of
('a'...'c').minmax => ["a", "b"]
This is because the C implementation of Range#minmax (range_minmax)
directly delegates to the C implementation of Range#min (range_min) and
Range#max (range_max), without changing the execution context.
Range#max's C implementation (range_max), when given a non-numeric
exclusive range, delegates to super, which is meant to call
Enumerable#max. However, because range_max is called directly by
range_minmax, super calls Enumerable#minmax instead, causing the
incorrect nesting.
Perhaps it is possible to change the execution context in an optimized
manner, but the simplest solution seems to be to just explicitly
delegate from Range#minmax to Range#min and Range#max.
Use static variables in Range#minmax
Diffstat (limited to 'version.h')
-rw-r--r-- | version.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2,7 +2,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 96 +#define RUBY_PATCHLEVEL 97 #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 7 |