Bug #7298

Behavior of Enumerator.new different between 1.9.3 and 2.0.0

Added by Ayumu AIZAWA almost 3 years ago. Updated almost 3 years ago.

[ruby-core:49001]
Status:Closed
Priority:Normal
Assignee:Ayumu AIZAWA
ruby -v:ruby 2.0.0dev (2012-11-07 trunk 37528) [x86_64-darwin12.2.0] Backport:

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]
#

$ ./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 `'


Related issues

Related to Ruby trunk - Feature #6636: Enumerable#size Closed 06/24/2012
Duplicated by Ruby trunk - Bug #7313: test_initialize(TestEnumerator) fails Closed 11/09/2012

Associated revisions

Revision 37609
Added by Marc-Andre Lafortune almost 3 years ago

Revert of 37541 "* test/ruby/test_enumerator.rb: Add test to shed light upon the bug"
[#7298]
This reverts commit 0ab21f9572d5d5f76b908aaf3381cde32a64c4c8.

Revision 37609
Added by Marc-Andre Lafortune almost 3 years ago

Revert of 37541 "* test/ruby/test_enumerator.rb: Add test to shed light upon the bug"
[#7298]
This reverts commit 0ab21f9572d5d5f76b908aaf3381cde32a64c4c8.

History

#1 Updated by Ayumu AIZAWA almost 3 years ago

  • Description updated (diff)

#2 Updated by Ayumu AIZAWA almost 3 years ago

r37498 makes this issue.

#3 Updated by Yusuke Endoh almost 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Marc-Andre Lafortune
  • Target version set to 2.0.0

Marc-Andre, please fix it by preview2.

Yusuke Endoh mame@tsg.ne.jp

#4 Updated by Marc-Andre Lafortune almost 3 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...

#5 Updated by Ayumu AIZAWA almost 3 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.

#6 Updated by Marc-Andre Lafortune almost 3 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?

#7 Updated by Ayumu AIZAWA almost 3 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.

#8 Updated by Marc-Andre Lafortune almost 3 years ago

  • Assignee changed from Marc-Andre Lafortune to Ayumu AIZAWA

#9 Updated by Luis Lavena almost 3 years ago

  • Category set to test
  • Priority changed from Normal to 7

#10 Updated by Luis Lavena almost 3 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

1) 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:in initialize'
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

#11 Updated by Marc-Andre Lafortune almost 3 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...?

Also available in: Atom PDF