[MacRuby-devel] MacRuby not finding a method that Ruby is
Edward Hynes
mred at dharmagaia.com
Wed Oct 7 19:37:02 PDT 2009
Hi,
I'm attempting to use the RParsec gem under MacRuby, but am getting a
NoMethodError when it loads. I've create a test file that simply adds
my local gem directory to the front of the library search path and
then calls "require 'rparsec'". This file runs fine under Ruby 1.9,
but produces the following error when called from MacRuby 0.4.
/Users/ehynes/Test/Gems/rparsec/parser.rb:32:in `block in init':
super: no superclass method `initialize:' for
RParsec::ValueParser:RParsec::ValueParser (NoMethodError)
from /Users/ehynes/Test/Gems/rparsec/parsers.rb:621:in `new'
from /Users/ehynes/Test/Gems/rparsec/parsers.rb:621:in
`<module:RParsec>'
from /Users/ehynes/Test/Gems/rparsec/parsers.rb:3:in `<top (required)>'
from /Users/ehynes/Test/Gems/rparsec.rb:3:in `require'
from /Users/ehynes/Test/Gems/rparsec.rb:3:in `block in <top
(required)>'
from /Users/ehynes/Test/Gems/rparsec.rb:2:in `each'
from /Users/ehynes/Test/Gems/rparsec.rb:2:in `<top (required)>'
from AbcParser.rb:2:in `require'
from AbcParser.rb:2:in `<main>'
The method with the error in the Parser class is:
def self.init(*vars)
parser_checker = {}
vars.each_with_index do |var, i|
name = var.to_s
parser_checker[i] = var if name.include?('parser') && !
name.include?('parsers')
end
define_method(:initialize) do |*params|
---> super() # <--- line 32
vars.each_with_index do |var, i|
param = params[i]
if parser_checker.include? i
TypeChecker.check_arg_type Parser, param, self, i
end
instance_variable_set("@"+var.to_s, param)
end
end
end
Any ideas as to why Ruby can call super in the above method, but
MacRuby can't? Is there a fix or workaround that I could use? An
alternate parser?
Thanks,
Ed
P.S. I did have to change one line in the RParsec parser.rb file to
get it to run under Ruby 1.9, replacing a ':' with a 'then' in a case
statement.
$ diff parser_original.rb parser.rb
881c881
< case c when String: c[0] else c end
---
> case c when String then c[0] else c end # ':' replaced with
'then'
More information about the MacRuby-devel
mailing list