[#99115] [Ruby master Bug#17023] How to prevent String memory to be relocated in ruby-ffi — larskanis@...
Issue #17023 has been reported by larskanis (Lars Kanis).
22 messages
2020/07/10
[#99375] [Ruby master Feature#17055] Allow suppressing uninitialized instance variable and method redefined verbose mode warnings — merch-redmine@...
Issue #17055 has been reported by jeremyevans0 (Jeremy Evans).
29 messages
2020/07/28
[#101207] [Ruby master Feature#17055] Allow suppressing uninitialized instance variable and method redefined verbose mode warnings
— merch-redmine@...
2020/12/02
Issue #17055 has been updated by jeremyevans0 (Jeremy Evans).
[#101231] Re: [Ruby master Feature#17055] Allow suppressing uninitialized instance variable and method redefined verbose mode warnings
— Austin Ziegler <halostatue@...>
2020/12/03
What does this mean?
[ruby-core:99181] [Ruby master Bug#17017] Range#max & Range#minmax incorrectly use Float end as max
From:
marcandre-ruby-core@...
Date:
2020-07-15 16:40:35 UTC
List:
ruby-core #99181
Issue #17017 has been updated by marcandre (Marc-Andre Lafortune).
jeremyevans0 (Jeremy Evans) wrote in #note-10:
> With current Ruby, you should use an endless range instead of range with an infinite end.
Endless ranges are 2.6+. Ruby 2.5 is not yet EOL. RuboCop supports 2.4 and other gems support earlier Rubies.
More importantly, endless range max is currently not useful... Note even `(4.2..).max` and variations return an infinity. I should open an issue about this...
> Note that if you use the exclusive range (`42...Float::INFINITY`), you would get a `TypeError` in 2.7.1, so it's not like we exclusively used `RangeError` for issues like these.
I agree with you, `TypeError` is also wrong.
> Mathematically, `42..Float::INFINITY` and `42...Float::INFINITY` represent the same range
We'll have to disagree with this 😅. I'm sure in some mathematical definition that it is the case, but in many others it is not. `42..Float::INFINITY` is not defined in traditional Euclidian space. On a Riemann sphere it is not the same as `42...Float::INFINITY`. If seen as sequences, you could see them as ω ("infinity") and ω - 1 which are distinct numbers (see surreal numbers), etc.
> All that said, I'm not completely opposed to special casing `Float::INFINITY` in this case.
Great. I hope we can make infinity handling useful.
----------------------------------------
Bug #17017: Range#max & Range#minmax incorrectly use Float end as max
https://bugs.ruby-lang.org/issues/17017#change-86560
* Author: sambostock (Sam Bostock)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-07-14T04:19:55Z master e60cd14d85) [x86_64-darwin17]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
While continuing to add edge cases to [`Range#minmax` specs](https://github.com/ruby/spec/pull/777), I discovered the following bug:
```ruby
(1..3.1).to_a == [1, 2, 3] # As expected
(1..3.1).to_a.max == 3 # As expected
(1..3.1).to_a.minmax == [1, 3] # As expected
(1..3.1).max == 3.1 # Should be 3, as above
(1..3.1).minmax == [1, 3.1] # Should be [1, 3], as above
```
One way to detect this scenario might be to do (whatever the C equivalent is of)
```ruby
range_end.is_a?(Numeric) // Is this a numeric range?
&& (range_end - range_begin).modulo(1) == 0 // Can we reach the range_end using the standard step size (1)
```
As for how to handle it, a couple options come to mind:
- We could error out and do something similar to what we do for exclusive ranges
```ruby
raise TypeError, 'cannot exclude non Integer end value'
```
- We might be able to calculate the range end by doing something like
```ruby
num_steps = (range_end / range_beg).to_i - 1 # one fewer steps than would exceed the range_end
max = range_beg + num_steps # take that many steps all at once
```
- We could delegate to `super` and enumerate the range to find the max
```ruby
super
```
- We could update the documentation to define the max for this case as the `range_end`, similarly to how the documentation for `include?` says it behaves like `cover?` for numeric ranges.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>