Project

General

Profile

Backport #6054

IO.foreach を Enumerator 化したときキーワード引数が無視される

Added by wanabe (_ wanabe) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-dev:45267]

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
'

Associated revisions

Revision 873b56fd
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34735
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054]

Revision 34735
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054]

Revision 34735
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054]

Revision 34735
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054]

Revision 34735
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054]

Revision 34735
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054]

Revision 35bf8099
Added by nobu (Nobuyoshi Nakada) over 7 years ago

merge revision(s) 34735,34736:

    * io.c (rb_io_s_foreach): return enumerator including kerword
      arguments.  [ruby-dev:45267][Bug #6054]

    * io.c (rb_io_s_foreach): argument check before making Enumerator.
      [ruby-dev:31525]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34749
Added by nobu (Nobuyoshi Nakada) over 7 years ago

merge revision(s) 34735,34736:

* io.c (rb_io_s_foreach): return enumerator including kerword
  arguments.  [ruby-dev:45267][Bug #6054]

* io.c (rb_io_s_foreach): argument check before making Enumerator.
  [ruby-dev:31525]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 7 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]
#2

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Status changed from Closed to Open
#3

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Tracker changed from Backport to Bug
  • Project changed from Backport193 to Ruby master

Updated by nobu (Nobuyoshi Nakada) over 7 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) over 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 50 to 100

Re-fixed at r34736 for [ruby-dev:31525].

#6

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193

Also available in: Atom PDF