Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: JRuby 1.6.7
-
Fix Version/s: None
-
Component/s: Interpreter
-
Labels:None
-
Environment:Mac OS X 10.7.3
$ uname -a
Darwin lon032maclocal.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
-
Number of attachments :
Description
What steps will reproduce the problem?
jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_33) [darwin-x86_64-java]
$ ruby -e "test = {'t' => 3}; test.each { test['e'] = 2 }"
RuntimeError: can't add a new key into hash during iteration
[]= at org/jruby/RubyHash.java:899
__file__ at -e:1
each at org/jruby/RubyHash.java:1181
(root) at -e:1
What is the expected output? What do you see instead?
I would expect the command to pass without failure
Additional information
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin11.3.0]
$ ruby -e "test = {'t' => 3}; test.each { test['e'] = 2 }"
-e:1:in `[]=': can't add a new key into hash during iteration (RuntimeError)
from -e:1:in `block in <main>'
from -e:1:in `each'
from -e:1:in `<main>'
ruby 1.8.7 (2012-06-29 patchlevel 370) [i686-darwin11.4.0]
$ ruby -e "test = {'t' => 3}; test.each { test['e'] = 2 }" //no error
jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_33) [darwin-x86_64-java]
$ ruby -e "test = {'t' => 3}; test.each { test['e'] = 2 }"
RuntimeError: can't add a new key into hash during iteration
[]= at org/jruby/RubyHash.java:907
__file__ at -e:1
each at org/jruby/RubyHash.java:1186
(root) at -e:1
This seems to be related to
JRUBY-4565. Was this meant to be implemented for all compatibility modes?