[MacRuby] #499: Order declaring class hierarchy gets MacRuby confused about instance variables
#499: Order declaring class hierarchy gets MacRuby confused about instance variables ------------------------------+--------------------------------------------- Reporter: paul@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ------------------------------+--------------------------------------------- The following code appears to misbehave in MacRuby. It defines a class hierarchy Alpha > Beta > Gamma, with methods to set and get instance variables. {{{ class Alpha end class Beta < Alpha def setAnotherVar @another_var = "Assigned to another_var in Beta" end end class Alpha def setVar=(var) @var = var end def var @var end end class Gamma < Beta def setAnotherVar @another_var = "Assigned to another_var in Gamma" end end a = Gamma.new a.setVar = "Assigned to var" puts a.var a.setAnotherVar puts a.var }}} Ruby 1.8.7 prints: Assigned to var[[BR]] Assigned to var Whereas MacRuby prints: Assigned to var[[BR]] Assigned to another_var in Gamma Ruby 1.8.7 would appear to be the correct behaviour. MacRuby is getting confused about instance variables. Setting the "another_var" instance variable wrongly changes the "var" instance variable. Declaring the classes strictly in the order of the hierarchy (i.e Alpha then Beta then Gamma) fixes the problem, but in a large project where classes are autoloaded, that may not happen. This is a simplified extraction from a larger project. It was a very elusive bug. Well, is it a bug? -- Ticket URL: <http://www.macruby.org/trac/ticket/499> MacRuby <http://macruby.org/>
#499: Order declaring class hierarchy gets MacRuby confused about instance variables ------------------------------+--------------------------------------------- Reporter: paul@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ------------------------------+--------------------------------------------- Comment(by lsansonetti@…): Definitely a bug... thanks for the report. -- Ticket URL: <http://www.macruby.org/trac/ticket/499#comment:1> MacRuby <http://macruby.org/>
On 11/12/2009, at 11:53 AM, MacRuby wrote:
#499: Order declaring class hierarchy gets MacRuby confused about instance variables ------------------------------+--------------------------------------------- Reporter: paul@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ------------------------------+---------------------------------------------
Comment(by lsansonetti@…):
Definitely a bug... thanks for the report.
This bug has not been fixed in MacRuby 0.5. Will it automatically migrate to being a 0.6 milestone? Paul Howson
#499: Order declaring class hierarchy gets MacRuby confused about instance variables ------------------------------+--------------------------------------------- Reporter: paul@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ------------------------------+--------------------------------------------- Comment(by lsansonetti@…): Filed into test_vm as r3131. -- Ticket URL: <http://www.macruby.org/trac/ticket/499#comment:2> MacRuby <http://macruby.org/>
#499: Order declaring class hierarchy gets MacRuby confused about instance variables ------------------------------+--------------------------------------------- Reporter: paul@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ------------------------------+--------------------------------------------- Comment(by conradwt@…): The correct behavior for a Ruby 1.9 VM prints as follows: Ruby 1.9.1: {{{ Assigned to var Assigned to var }}} Ruby 1.9.2: {{{ Assigned to var Assigned to var }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/499#comment:3> MacRuby <http://macruby.org/>
#499: Order declaring class hierarchy gets MacRuby confused about instance variables ------------------------------+--------------------------------------------- Reporter: paul@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: MacRuby 0.7 Component: MacRuby | Resolution: fixed Keywords: | ------------------------------+--------------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: MacRuby 0.5 => MacRuby 0.7 Comment: This should be fixed in trunk (as least since r4119). -- Ticket URL: <http://www.macruby.org/trac/ticket/499#comment:4> MacRuby <http://macruby.org/>
participants (2)
-
MacRuby
-
Paul Howson