Project

General

Profile

Actions

Bug #7298

closed

Behavior of Enumerator.new different between 1.9.3 and 2.0.0

Added by ayumin (Ayumu AIZAWA) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.0.0dev (2012-11-07 trunk 37528) [x86_64-darwin12.2.0]
Backport:
[ruby-core:49001]

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 `'


Related issues 2 (0 open2 closed)

Related to Ruby master - Feature #6636: Enumerable#sizeClosedmarcandre (Marc-Andre Lafortune)06/24/2012Actions
Has duplicate Ruby master - Bug #7313: test_initialize(TestEnumerator) failsClosedmarcandre (Marc-Andre Lafortune)11/09/2012Actions

Updated by ayumin (Ayumu AIZAWA) over 11 years ago

  • Description updated (diff)

Updated by ayumin (Ayumu AIZAWA) over 11 years ago

r37498 makes this issue.

Updated by mame (Yusuke Endoh) over 11 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

Updated by marcandre (Marc-Andre Lafortune) over 11 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) over 11 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) over 11 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) over 11 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) over 11 years ago

  • Assignee changed from marcandre (Marc-Andre Lafortune) to ayumin (Ayumu AIZAWA)

Updated by luislavena (Luis Lavena) over 11 years ago

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

Updated by luislavena (Luis Lavena) over 11 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

Updated by marcandre (Marc-Andre Lafortune) over 11 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...?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0