Projects

Ticket #513 (new defect)

Opened 2 years ago

Last modified 14 months ago

MacRuby gets confused about inheritance under certain conditions

Reported by: matthew@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 1.0
Component: MacRuby Keywords:
Cc: matthew@…

Description

Given the following code,

module Foo
  module Baz
    def initialize(a, b)
    end
  end
end

module Foo
  module Bar
    module Baz
      include Foo::Baz

      def initialize(a, b, c, d)
        super(a, b)
      end
    end
  end
end

module Foo
  module Bar
    module Quux
      include Baz
    end
  end
end

module Foo
  module Bar
    module Baz
      class Bat
        include Foo::Bar::Baz
        include Foo::Bar::Quux
      end
    end
  end
end

There are two related errors associated with this piece of code.

1.

Foo::Bar::Baz::Bat.new

Expected result (Ruby 1.9.1)

ArgumentError: wrong number of arguments (0 for 4)

Actual result (MacRuby 0.5b2)

=> #<Foo::Bar::Baz::Bat:0x200252380>

Note the difference in response from #512!

2.

Foo::Bar::Baz::Bat.new(nil, nil, nil, nil)

Expected result (Ruby 1.9.1)

=> #<Foo::Bar::Baz::Bat:0x913598>

Actual result (MacRuby 0.5b2)

ArgumentError: wrong number of arguments (4 for 2)

It seems that MacRuby is becoming confused. Here are a few ways to make it understand that Foo::Bar::Baz::Bat#initialize should accept 4 arguments.

- Comment out Foo::Bar::Baz::Bat's second include statement (line 33)
- Comment out Foo::Bar::Quux's include statement (line 23)
- Comment out Foo::Bar::Baz's include statement (line 11) and Foo::Bar::Baz#initialize's super call (line 14)

Of course, for my application I need the original functionality, so none of those will work for me. :-) If you find a workaround while investigating, please let me know.

Attachments

513.rb Download (0.7 KB) - added by emil@… 14 months ago.
reduction

Change History

  Changed 2 years ago by matthew@…

  • cc matthew@… added

Cc Me!

in reply to: ↑ description   Changed 2 years ago by matthew@…

Replying to matthew@…:

I was looking at this again and realized that I had included an extra line in the repro case.

This:

module Foo
  module Bar
    module Baz
      class Bat
        include Foo::Bar::Baz
        include Foo::Bar::Quux
      end
    end
  end
end

should be:

module Foo
  module Bar
    module Baz
      class Bat
        include Foo::Bar::Quux
      end
    end
  end
end

In other words, the first include here is irrelevant.

  Changed 15 months ago by mattaimonetti@…

still valid as of today

Changed 14 months ago by emil@…

reduction

  Changed 14 months ago by emil@…

persists in trunk rev 4976

  Changed 14 months ago by lsansonetti@…

  • milestone set to MacRuby 1.0

Let's try to fix this very scary bug in 1.0.

Note: See TracTickets for help on using tickets.