Randomly changed hash key in overriden []= method in Hash inherited class
-------------------------------------------------------------------------

                 Key: JRUBY-6035
                 URL: https://jira.codehaus.org/browse/JRUBY-6035
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.6.4, JRuby 1.6.2
         Environment: Ubuntu 10.04 (2.6.32-33)
java 1.6.0_26-b03
            Reporter: Ivan Vystoskiy


Found this problem trying to run Machinist v2.0.0beta2 but it happens in irb as 
well. 
Here is a snippet I ran in a console. In my environment it randomly fails on 
48th-49th iteration. After self[*keys] = [] empty array get added to keys and 
having the key is changed super(key) returns nil.

class AA < Hash
  def []=(*keys)
    value = keys.pop
    super(keys, value)
  end

  def [](*keys)
    if !has_key?(keys)
      p keys
      self[*keys] = []
      p keys
    end
    super(keys)
  end
end

def go(h,count)
  count.times do |i|
    key=[i,i]
    h[key]<<i
  end
end

go(AA.new, 100)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to