[MacRuby] #868: Should not get a value until calling Hash#rehash when Object of Hash's key was changed.
#868: Should not get a value until calling Hash#rehash when Object of Hash's key was changed. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Test Script: {{{ #!ruby $ cat test_rehash.rb def assert_equal(a, b) p b p a == b puts "-----" end def assert_nil(a) p a p a == nil puts "-----" end a = [ "a", "b" ] c = [ "c", "d" ] h = { a => 100, c => 300 } assert_equal(100, h[a]) a[0] = "z" assert_nil(h[a]) h.rehash assert_equal(100, h[a]) }}} Result of Ruby 1.9.1: {{{ $ ruby test_rehash.rb 100 true ----- nil true ----- 100 true ----- }}} Result of MacRuby Trunk: {{{ $ macruby test_rehash.rb 100 true ----- 100 false ----- 100 true ----- }}} This problem may be related to #791. -- Ticket URL: <http://www.macruby.org/trac/ticket/868> MacRuby <http://macruby.org/>
#868: Should not get a value until calling Hash#rehash when Object of Hash's key was changed. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Changes (by watson1978@…): * priority: blocker => minor -- Ticket URL: <http://www.macruby.org/trac/ticket/868#comment:1> MacRuby <http://macruby.org/>
#868: Should not get a value until calling Hash#rehash when Object of Hash's key was changed. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): I also think it's related to #791. The problem does not appear if I replace a[0]='z' by a<<'z' (which changes the hash code). Internally, we do hash lookup based on 2 operations: first we retrieve the hash code and second we check for key equality. In MRI, since the hash code is different, it returns nil immediately (even if the key is equal). In MacRuby, the hash code is the same. -- Ticket URL: <http://www.macruby.org/trac/ticket/868#comment:2> MacRuby <http://macruby.org/>
#868: Should not get a value until calling Hash#rehash when Object of Hash's key was changed. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: minor | Milestone: MacRuby Later Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * milestone: => MacRuby Later Comment: Like #791, I think this is a bug for Later. -- Ticket URL: <http://www.macruby.org/trac/ticket/868#comment:3> MacRuby <http://macruby.org/>
#868: Should not get a value until calling Hash#rehash when Object of Hash's key was changed. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: minor | Milestone: MacRuby 0.9 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: MacRuby Later => MacRuby 0.9 Comment: This bug has been fixed in r5042. -- Ticket URL: <http://www.macruby.org/trac/ticket/868#comment:4> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby