[MacRuby] #549: Class variables are not initialised properly.
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: class, instance -------------------------------------+-------------------------------------- The mime-types gem has a class and an instance interface. The class interface uses an instance of itself. However, it doesn’t work in MacRuby. It does not seem to be initialised properly. I have included in a sample code with the expected behaviour. Changing @__types__ to @@__types__ will not fix it. #!/usr/bin/env macruby class Test def initialize() @foo = true end def add(something) puts "Is foo nil: #{@foo.nil?}" end @__types__ = self.new() def self.add(something) @__types__.add(something) end end t = Test.new t.add(3) Test.add(4) Output (MacRuby 0.5) Is foo nil: false Is foo nil: true Expected (Ruby 1.9.1/1.8.7) Is foo nil: false Is foo nil: false -- Ticket URL: <http://www.macruby.org/trac/ticket/549> MacRuby <http://macruby.org/>
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: class, instance -------------------------------------+-------------------------------------- Comment(by sorin.ionescu@…): Trac totally butchered the code sample. DISREGARD IT AND SEE ATTACHMENT INSTEAD. -- Ticket URL: <http://www.macruby.org/trac/ticket/549#comment:1> MacRuby <http://macruby.org/>
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: class, instance -------------------------------------+-------------------------------------- Description changed by martinlagardette@…: Old description:
The mime-types gem has a class and an instance interface. The class interface uses an instance of itself. However, it doesn’t work in MacRuby. It does not seem to be initialised properly. I have included in a sample code with the expected behaviour. Changing @__types__ to @@__types__ will not fix it.
#!/usr/bin/env macruby
class Test def initialize() @foo = true end
def add(something) puts "Is foo nil: #{@foo.nil?}" end
@__types__ = self.new()
def self.add(something) @__types__.add(something) end end
t = Test.new t.add(3) Test.add(4)
Output (MacRuby 0.5) Is foo nil: false Is foo nil: true
Expected (Ruby 1.9.1/1.8.7) Is foo nil: false Is foo nil: false
New description: The mime-types gem has a class and an instance interface. The class interface uses an instance of itself. However, it doesn’t work in MacRuby. It does not seem to be initialised properly. I have included in a sample code with the expected behaviour. Changing @__types__ to @@__types__ will not fix it. {{{ #!/usr/bin/env macruby class Test def initialize() @foo = true end def add(something) puts "Is foo nil: #{@foo.nil?}" end @__types__ = self.new() def self.add(something) @__types__.add(something) end end t = Test.new t.add(3) Test.add(4) }}} Output (MacRuby 0.5) {{{ Is foo nil: false Is foo nil: true }}} Expected (Ruby 1.9.1/1.8.7) {{{ Is foo nil: false Is foo nil: false }}} -- -- Ticket URL: <http://www.macruby.org/trac/ticket/549#comment:2> MacRuby <http://macruby.org/>
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: class, instance -------------------------------------+-------------------------------------- Description changed by martinlagardette@…: Old description:
The mime-types gem has a class and an instance interface. The class interface uses an instance of itself. However, it doesn’t work in MacRuby. It does not seem to be initialised properly. I have included in a sample code with the expected behaviour. Changing @__types__ to @@__types__ will not fix it.
{{{ #!/usr/bin/env macruby
class Test def initialize() @foo = true end
def add(something) puts "Is foo nil: #{@foo.nil?}" end
@__types__ = self.new()
def self.add(something) @__types__.add(something) end end
t = Test.new t.add(3) Test.add(4) }}}
Output (MacRuby 0.5) {{{ Is foo nil: false Is foo nil: true }}} Expected (Ruby 1.9.1/1.8.7) {{{ Is foo nil: false Is foo nil: false }}}
New description: The mime-types gem has a class and an instance interface. The class interface uses an instance of itself. However, it doesn’t work in MacRuby. It does not seem to be initialised properly. I have included in a sample code with the expected behaviour. Changing `@__types__` to `@@__types__` will not fix it. {{{ #!/usr/bin/env macruby class Test def initialize() @foo = true end def add(something) puts "Is foo nil: #{@foo.nil?}" end @__types__ = self.new() def self.add(something) @__types__.add(something) end end t = Test.new t.add(3) Test.add(4) }}} Output (MacRuby 0.5) {{{ Is foo nil: false Is foo nil: true }}} Expected (Ruby 1.9.1/1.8.7) {{{ Is foo nil: false Is foo nil: false }}} -- -- Ticket URL: <http://www.macruby.org/trac/ticket/549#comment:3> MacRuby <http://macruby.org/>
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: class, instance -------------------------------------+-------------------------------------- Description changed by martinlagardette@…: Old description:
The mime-types gem has a class and an instance interface. The class interface uses an instance of itself. However, it doesn’t work in MacRuby. It does not seem to be initialised properly. I have included in a sample code with the expected behaviour. Changing `@__types__` to `@@__types__` will not fix it.
{{{ #!/usr/bin/env macruby
class Test def initialize() @foo = true end
def add(something) puts "Is foo nil: #{@foo.nil?}" end
@__types__ = self.new()
def self.add(something) @__types__.add(something) end end
t = Test.new t.add(3) Test.add(4) }}}
Output (MacRuby 0.5) {{{ Is foo nil: false Is foo nil: true }}} Expected (Ruby 1.9.1/1.8.7) {{{ Is foo nil: false Is foo nil: false }}}
New description: The mime-types gem has a class and an instance interface. The class interface uses an instance of itself. However, it doesn’t work in MacRuby. It does not seem to be initialised properly. I have included in a sample code with the expected behaviour. Changing `@__types__` to `@@__types__` will not fix it. {{{ class MacRubyInitTest def initialize @foo = true end def add p self puts "@foo = " + @foo.inspect end @__types__ = self.new() def self.add @__types__.add end end t = MacRubyInitTest.new t.add MacRubyInitTest.add }}} Output (MacRuby 0.5) {{{ <MacRubyInitTest:0x200024d80 @foo=true> @foo = true <MacRubyInitTest:0x200024e00 @foo=true> @foo = nil }}} Expected (Ruby 1.9.1/1.8.7) {{{ #<MacRubyInitTest:0x00000100847920 @foo=true> @foo = true #<MacRubyInitTest:0x00000100847a70 @foo=true> @foo = true }}} -- -- Ticket URL: <http://www.macruby.org/trac/ticket/549#comment:4> MacRuby <http://macruby.org/>
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: class, instance -------------------------------------+-------------------------------------- Comment(by martinlagardette@…): Hi Sorin! Thanks for the report. Are you sure, though, that this bug is a "blocker"? To everyone: the attached file can be ignored, I edited the bug description to format the code, and modified it a little to show some interesting facts: `p self` shows that the `@foo` variable is set to true, however, `@foo` is `nil`. -- Ticket URL: <http://www.macruby.org/trac/ticket/549#comment:5> MacRuby <http://macruby.org/>
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: class, instance -------------------------------------+-------------------------------------- Comment(by sorin.ionescu@…): It is a blocker. The mime-types gem that uses it is quite popular if not the only one. Thanks for fixing the report. -- Ticket URL: <http://www.macruby.org/trac/ticket/549#comment:6> MacRuby <http://macruby.org/>
#549: Class variables are not initialised properly. -------------------------------------+-------------------------------------- Reporter: sorin.ionescu@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.7 Component: MacRuby | Resolution: fixed Keywords: class, instance | -------------------------------------+-------------------------------------- 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/549#comment:7> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby