Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.4
-
Fix Version/s: JRuby 1.6RC1
-
Component/s: Core Classes/Modules, RubySpec
-
Labels:None
-
Number of attachments :
Description
New RubySpec enforces this:
commit 2ae272118ce7e0068d5087cd321a8aa551ced581
Author: Yusuke Endoh <mame@tsg.ne.jp>
Date: Wed Feb 17 01:29:16 2010 +0900
adding new key into hash during iteration always raises an exception
matz agreed. [ruby-core:23614]
jruby -S mspec ci core\hash jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2010-02-16 2770c7f) (Java HotSpot(TM) Client VM 1.6.0_18) [x86-java] ...............F....................F.........F........ 1) Hash#[]= raises RuntimeErrors if attempt to add new key during iteration FAILED Expected RuntimeError but no exception was raised D:/work/jruby-dev/rubyspec.git/core/hash/shared/store.rb:56 D:/work/jruby-dev/rubyspec.git/core/hash/element_set_spec.rb:5 D:/work/jruby-dev/rubyspec.git/core/hash/element_set_spec.rb:56:in `load' D:/work/jruby-dev/mspec.git/bin/mspec-ci:8 2) Hash#merge! raises RuntimeErrors if attempt to add new key during iteration FAILED Expected RuntimeError but no exception was raised D:/work/jruby-dev/rubyspec.git/core/hash/merge_spec.rb:66 D:/work/jruby-dev/rubyspec.git/core/hash/merge_spec.rb:58 D:/work/jruby-dev/rubyspec.git/core/hash/merge_spec.rb:56:in `load' D:/work/jruby-dev/mspec.git/bin/mspec-ci:8 3) Hash#store raises RuntimeErrors if attempt to add new key during iteration FAILED Expected RuntimeError but no exception was raised D:/work/jruby-dev/rubyspec.git/core/hash/shared/store.rb:56 D:/work/jruby-dev/rubyspec.git/core/hash/store_spec.rb:5 D:/work/jruby-dev/rubyspec.git/core/hash/store_spec.rb:56:in `load' D:/work/jruby-dev/mspec.git/bin/mspec-ci:8 Finished in 0.781000 seconds
I don't know when it's fixed (since I didn't run bisect), but this is fixed in trunk now.
$ jruby -v -e 'hash = {1 => 2, 3 => 4, 5 => 6}; hash.each { hash.send(:store, :foo, :bar) }' jruby 1.6.0.dev (ruby 1.8.7 patchlevel 249) (2010-07-31 e46037a) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java] -e:1: can't add a new key into hash during iteration (RuntimeError) from -e:1:in `each' from -e:1 $ jruby -v --1.9 -e 'hash = {1 => 2, 3 => 4, 5 => 6}; hash.each { hash.send(:store, :foo, :bar) }' jruby 1.6.0.dev (ruby 1.9.2dev trunk -1) (2010-07-31 e46037a) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java] -e:1: can't add a new key into hash during iteration (RuntimeError) from -e:1:in `each' from -e:1