[ruby-core:114990] [Ruby master Bug#19855] Array#bsearch gets wrong result when its block returns a non-integer numeric value.
From:
"usa (Usaku NAKAMURA) via ruby-core" <ruby-core@...>
Date:
2023-10-10 11:02:32 UTC
List:
ruby-core #114990
Issue #19855 has been updated by usa (Usaku NAKAMURA).
Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE to 3.0: REQUIRED, 3.1: DONE, 3.2: DONE
ruby_3_1 eb54ed809f61fb25a0de101a7a6a649e8d4a434c merged revision(s) a28c5151f567cada0d2f5c0c3ec4df7f97b80784.
----------------------------------------
Bug #19855: Array#bsearch gets wrong result when its block returns a non-integer numeric value.
https://bugs.ruby-lang.org/issues/19855#change-104860
* Author: kyanagi (Kouhei Yanagita)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-08-29T04:52:18Z master c0e913ae88) [arm64-darwin22]
* Backport: 3.0: REQUIRED, 3.1: DONE, 3.2: DONE
----------------------------------------
Array#bsearch gets wrong result when its block returns a non-integer numeric value.
```
% ruby -e 'p [0, 4, 7, 10, 12].bsearch { |x| (4 - x) }'
4
% ruby -e 'p [0, 4, 7, 10, 12].bsearch { |x| (4 - x).to_r }'
nil
```
fix: https://github.com/ruby/ruby/pull/8314
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/