[#103241] [Ruby master Bug#17777] 2.6.7 fails to build on macOS: implicit declaration of function 'rb_native_mutex_destroy' is invalid in C99 — eregontp@...
Issue #17777 has been reported by Eregon (Benoit Daloze).
17 messages
2021/04/05
[#103305] [Ruby master Feature#17785] Allow named parameters to be keywords — marcandre-ruby-core@...
Issue #17785 has been reported by marcandre (Marc-Andre Lafortune).
21 messages
2021/04/08
[#103342] [Ruby master Feature#17790] Have a way to clear a String without resetting its capacity — jean.boussier@...
Issue #17790 has been reported by byroot (Jean Boussier).
14 messages
2021/04/09
[#103388] [ANN] Multi-factor Authentication of bugs.ruby-lang.org — SHIBATA Hiroshi <hsbt@...>
Hello,
5 messages
2021/04/12
[#103414] Re: [ANN] Multi-factor Authentication of bugs.ruby-lang.org
— Martin J. Dürst <duerst@...>
2021/04/13
Is there a way to use this multi-factor authentication for (like me)
[#103547] List of CI sites to check — Martin J. Dürst <duerst@...>
Hello everybody,
4 messages
2021/04/22
[#103596] [Ruby master Feature#17830] Add Integer#previous and Integer#prev — rafasoaresms@...
Issue #17830 has been reported by rafasoares (Rafael Soares).
9 messages
2021/04/26
[ruby-core:103355] [Ruby master Feature#16816] Prematurely terminated Enumerator should stay terminated
From:
merch-redmine@...
Date:
2021-04-09 21:24:36 UTC
List:
ruby-core #103355
Issue #16816 has been updated by jeremyevans0 (Jeremy Evans).
Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN)
ruby -v deleted (all)
Tracker changed from Bug to Feature
I prepared a commit to fix this: https://github.com/jeremyevans/ruby/commit/851534bbffd87c79bb63e8df36d6a47cc821aef0
Unfortunately, it breaks a CSV test:
```
1) Failure:
TestCSVParseInvalid#test_ignore_invalid_line [/home/runner/work/ruby/ruby/src/test/csv/parse/test_invalid.rb:34]:
<false> expected but was
<true>.
```
This failure shows the general problem with the idea. Basically, when enumerating has side effects, such as reading from a file, after an error is raised, you may want to continue enumerating after the error. Because the file state has changed, this is not equivalent to restarting from the beginning, it's equivalent to picking up where you left off.
So this isn't a change we would want to make by default. We would only want it for stateless enumerators, and we don't currently differentiate between enumerators that have external state and those that do not.
I think the current behavior makes sense for enumerators having external state. So I conclude this is not a bug, but a feature request, and one that could only be made if Ruby decided to differentiate the two types of enumerators.
----------------------------------------
Feature #16816: Prematurely terminated Enumerator should stay terminated
https://bugs.ruby-lang.org/issues/16816#change-91446
* Author: headius (Charles Nutter)
* Status: Open
* Priority: Normal
----------------------------------------
When iterating over an Enumerator, there are three different possible results of calling `next`:
1. The next item is returned and a cursor is advanced
2. There's no next item and the Enumerator will forever raise `StopIteration`
3. There's an error getting the next item which is raised out of `next`
This third case has some unexpected behavior that I discovered while working on https://github.com/jruby/jruby/issues/6157
It seems that when an Enumerator fails prematurely with an exception, any subsequent call to #next will cause it to restart.
This can be seen in a simple script I used to write a ruby/spec in https://github.com/jruby/jruby/pull/6190
```ruby
Enumerator.new {
2.times {|i| raise i.to_s }
}.tap {|f|
p 2.times.map { f.next rescue $!.message }
}
```
The output from this is `[0, 0]`. After the iteration fails, the second `next` call causes it to restart and it fails again.
Contrast this to the behavior of item 3 above; when an Enumerator finishes iterating without error, it remains "finished" forever and can't be restarted.
I believe the restarting behavior is at best undocumented behavior and at worst incorrect and unspected. Take this example:
```ruby
e = Enumerator.new { |y|
c = new_database_cursor
5.times { y.yield c.next_result }
}
```
If `next_result` here raises an error, a subsequent call to `next` on this enumerator will cause it to restart, re-acquire the cursor, and begin again.
As another example I ask a question: how do you indicate that an Enumerator failed due to an error, and *keep it failed* so it doesn't restart again?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>