Projects

Ticket #19 (closed defect: fixed)

Opened 4 years ago

Last modified 14 months ago

Problems with method_missing

Reported by: vincent.isambart@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.8
Component: MacRuby Keywords:
Cc:

Description (last modified by lsansonetti@…) (diff)

~/tmp% cat e.rb
module Kernel
def method_missing(method_name, *args)
  puts "method #{method_name} missing"
  super
end
end

Object.new.unknown_method
~/tmp% ruby e.rb
method unknown_method missing
e.rb:4:in `method_missing': super: no superclass method `unknown_method' (NoMethodError)
	from e.rb:8
~/tmp% ruby-1.9 e.rb
method unknown_method missing
e.rb:4:in `method_missing': undefined method `unknown_method' for #<Object:0x0a25d0> (NoMethodError)
	from e.rb:8:in `<main>'
~/tmp% macruby e.rb
e.rb:8:in `<main>': undefined method `unknown_method' for #<Object:0x10af150> (NoMethodError)

You can see that in MacRuby the redefined method_missing function is not called.

And if you replace "module Kernel" by "class NSObject", MacRuby crashes...

Change History

Changed 4 years ago by lsansonetti@…

  • description modified (diff)
  • milestone set to MacRuby 1.0

Changed 4 years ago by lsansonetti@…

  • milestone changed from MacRuby 1.0 to MacRuby 0.3

Should be fixed once we switch to the objc dispatcher.

Changed 3 years ago by lsansonetti@…

  • milestone changed from MacRuby 0.3 to MacRuby 0.4

Still not fixed in trunk, punting for 0.4.

Changed 3 years ago by mattaimonetti@…

trying the sample code under macirb segfaults on trunk from today.

Changed 2 years ago by lsansonetti@…

  • milestone changed from MacRuby 0.4 to MacRuby 0.5

Works better with trunk, but still not perfect.

$ ./miniruby  t.rb 
method unknown_method missing
wrong number of arguments (1 for 0) (ArgumentError)

I suspect the exception is raised from the super call.

Changed 14 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from MacRuby 0.5 to MacRuby 0.8

Looks like it's fixed for me in trunk.

$ ./miniruby t.rb 
method unknown_method missing
/Users/lrz/src/macruby-trunk/t.rb:4:in `method_missing:': super: no superclass method `method_missing' for #<NSObject:0x4004a0800> (NoMethodError)
	from /Users/lrz/src/macruby-trunk/t.rb:8:in `<main>'
$ ruby t.rb 
method unknown_method missing
t.rb:4:in `method_missing': super: no superclass method `unknown_method' (NoMethodError)
	from t.rb:8
Note: See TracTickets for help on using tickets.