Bug #7298
closedBehavior of Enumerator.new different between 1.9.3 and 2.0.0
Description
Under 1.9.3, when Enumerator.new was called with arguments and block, it return Enumerator object.
But under trunk, it makes TypeError.
$ ruby -v -e "p Enumerator.new([1,2,3]){|y|y.yield 4}"
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.2]
#<Enumerator: [1, 2, 3]:each>
$ ./ruby -v -e "p Enumerator.new([1,2,3]){|y|y.yield 4}"
ruby 2.0.0dev (2012-11-07 trunk 37528) [x86_64-darwin12.2.0]
-e:1:in initialize': can't convert Array into Integer (TypeError) from -e:1:in
new'
from -e:1:in `'
Updated by ayumin (Ayumu AIZAWA) almost 12 years ago
- Description updated (diff)
Updated by ayumin (Ayumu AIZAWA) almost 12 years ago
r37498 makes this issue.
Updated by mame (Yusuke Endoh) almost 12 years ago
- Status changed from Open to Assigned
- Assignee set to marcandre (Marc-Andre Lafortune)
- Target version set to 2.0.0
Marc-Andre, please fix it by preview2.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by marcandre (Marc-Andre Lafortune) almost 12 years ago
- Status changed from Assigned to Closed
Sorry, completely forgot to check rubyspec. Fixed.
I'll take this occasion to open a new feature request sitting on my todo list for over a year...
Updated by ayumin (Ayumu AIZAWA) almost 12 years ago
- Status changed from Closed to Open
Hi Mark,
You fixed rubyspec... just skipped. I think this is not fair.
Same example still reproduce same problem.
As mame said it should be fixed until preview2.
I added more example in test/ruby/test_enumerator.rb to shed light on this issue by r37541.
Updated by marcandre (Marc-Andre Lafortune) almost 12 years ago
- Status changed from Open to Feedback
Sorry, I am missing your point. There was no meaning to the form Enumerator.new( obj ) { block }
; the block was completely ignored and there should have been a warning (like there is for Array.new, #index, #count, ...)
What is the meaning of {|y| i = 0; loop { y << (i+=1) } }
in your test? Do you think it does anything?
Updated by ayumin (Ayumu AIZAWA) almost 12 years ago
- Status changed from Feedback to Assigned
Hi Mark,
The given block has no mean.
It is just same as above example. I wanted to show that this issue is not closed yet by testcode.
I agreed what you said.
When Enumerator.new called with args and blok, the block is ignored and it should have been a warning. Thus, I will fix example. (after my daywork)
Thanks.
Updated by marcandre (Marc-Andre Lafortune) almost 12 years ago
- Assignee changed from marcandre (Marc-Andre Lafortune) to ayumin (Ayumu AIZAWA)
Updated by luislavena (Luis Lavena) almost 12 years ago
- Category set to test
- Priority changed from Normal to 7
Hello,
I'm bumping the priority on this since it broke the build:
http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20121109T003800Z.log.html.gz#test-all
http://ci.rubyinstaller.org/job/ruby-trunk-x86-test-all/271/console
Thank you
Updated by luislavena (Luis Lavena) almost 12 years ago
=begin
ping?
20 hours have past and failure is still there:
http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20121109T163100Z.log.html.gz#test-all
http://ci.rubyinstaller.org/job/ruby-trunk-x86-test-all/275/console
- Error:
test_initialize(TestEnumerator):
TypeError: can't convert Array into Integer
C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_enumerator.rb:72:ininitialize' C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_enumerator.rb:72:in
new'
C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_enumerator.rb:72:in `test_initialize'
=end
Updated by marcandre (Marc-Andre Lafortune) almost 12 years ago
- Status changed from Assigned to Closed
- Priority changed from 7 to Normal
I reverted Ayumin's commit, although I had understood that he would do it himself...?