[#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:99206] [Ruby master Bug#17034] Unexpected behavior in #max for beginless range
From:
citizen428@...
Date:
2020-07-17 16:26:41 UTC
List:
ruby-core #99206
Issue #17034 has been updated by citizen428 (Michael Kohl).
File range-max-beginless.patch added
citizen428 (Michael Kohl) wrote:
> I think this is not ideal. Possible solutions:
>
> 1. Return `e` (`RANGE_END(range)` for beginless ranges or
> 2. return a `RangeError` with a message like "cannot get the maximum of beginless range" (similar to `.min`).
I had some time and looked into this. For inclusive integer ranges `r.end` will now be returned, no other behavior changes. Patch attached, but since the diff is very small I also opened a PR:
https://github.com/ruby/ruby/pull/3328/
----------------------------------------
Bug #17034: Unexpected behavior in #max for beginless range
https://bugs.ruby-lang.org/issues/17034#change-86584
* Author: citizen428 (Michael Kohl)
* Status: Open
* Priority: Normal
* ruby -v: 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
When calling `max` on a beginless range, a non-intuitive error gets raised:
``` ruby
r = ..9
r.max
# ArgumentError: comparison of NilClass with 9 failed
```
There's a check for `NIL_P(RANGE_BEG(range))` but it's inside another check which is false for the example case above:
``` ruby
if (rb_block_given_p() || (EXCL(range) && !nm) || argc) {
if (NIL_P(RANGE_BEG(range))) {
rb_raise(rb_eRangeError, "cannot get the maximum of beginless range with custom comparison method");
}
return rb_call_super(argc, argv);
}
```
The first part of the condition is false since there is no block, and even though I'm not sure what `EXCL` does the second part of the condition will be false due to `!nm` (`nm` will be true because of `FIXNUM_P(e)`). So I think the error gets raised here:
``` ruby
int c = OPTIMIZED_CMP(b, e, cmp_opt);
```
I think this is not ideal. Possible solutions:
1. Return `e` (`RANGE_END(range)` for beginless ranges or
2. return a `RangeError` with a message like "cannot get the maximum of beginless range" (similar to `.min`).
Happy to provide a patch if people want this changed and can agree on what the new behavior should be.
---Files--------------------------------
range-max-beginless.patch (1.26 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>