Backport #6054
closedIO.foreach を Enumerator 化したときキーワード引数が無視される
Description
http://toro.2ch.net/test/read.cgi/tech/1324826777/666-675 で指摘があったのですが
末尾に示すように、IO.foreach にブロックを渡さず Enumerator 化したときキーワード引数が無視されます。
上の書き込みによると "先にハッシュオプション取り除いてからEnumeratorを生成しちゃってるのでハッシュオプションがEnumeratorには反映されない" とのことでした。
rb_io_s_foreach 中の RETURN_ENUMERATOR を rb_scan_args より先にするべきではないか、ということのようです。
$ cat foo.rb
p IO.foreach(FILE,mode:"a").next
IO.foreach(FILE,mode:"a") {|l| p l }
$ ruby -v foo.rb
ruby 2.0.0dev (2012-02-21 trunk 34711) [i686-linux]
"p IO.foreach(FILE,mode:"a").next\n"
foo.rb:2:in foreach': not opened for reading (IOError) from foo.rb:2:in
'
Updated by nobu (Nobuyoshi Nakada) almost 13 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r34735.
_, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- io.c (rb_io_s_foreach): return enumerator including kerword
arguments. [ruby-dev:45267][Bug #6054]
Updated by nobu (Nobuyoshi Nakada) almost 13 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport193
- Status changed from Closed to Open
Updated by nobu (Nobuyoshi Nakada) almost 13 years ago
- Tracker changed from Backport to Bug
- Project changed from Backport193 to Ruby master
Updated by nobu (Nobuyoshi Nakada) almost 13 years ago
- % Done changed from 100 to 50
- ruby -v set to ruby 2.0.0dev (2012-02-21 trunk 34711) [i686-linux]
Updated by nobu (Nobuyoshi Nakada) almost 13 years ago
- Status changed from Open to Closed
- % Done changed from 50 to 100
Re-fixed at r34736 for [ruby-dev:31525].
Updated by nobu (Nobuyoshi Nakada) almost 13 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport193