Open millisami opened 14 years ago
I was looking at the code for this. The method involved is:
def process(ast, scope = nil)
case Array(ast)[0]
when :module, :class
name = ast[1]
new_scope = Scope.new(name, ast[2])
if scope
scope.scopes[name] = new_scope
elsif @scopes[name]
new_scope = @scopes[name]
else
@scopes[name] = new_scope
end
process(ast[3], new_scope)
when :imethod
ast.shift
scope.instance_methods << Method.new(*ast)
when :cmethod
ast.shift
scope.class_methods << Method.new(*ast)
when Array
ast.map { |a| process(a, scope) }
end
end
So the problem is that scope
can, in certain cases, be nil
. Unfortunately I don't know enough about what this method is accomplishing to be sure of a proper fix.
Does this address the problem?
https://github.com/defunkt/tomdoc/blob/tomdoc.rb/lib/tomdoc/source_parser.rb#L89
I really wouldn't have expected this error. What does a nil scope mean? I'm guessing that a nil scope can only happen for toplevel? I mean how else could a nil scope be possible? Not sure what the proper reference for toplevel is in the @scopes hash, so this still needs to be fixed.
@millisami Can you post your example file?
Scratch that, I can reproduce :)
alright!
Api test
MWF5MTcyYS01YzQ5LTQ1MGMtODkzMy0yNTdlNGAeOTIyNmJfd2lucGxhY2Vob2xkAXR8AWIuc2l0AS9eb21tYW5kcy3=!
I installed tomdoc and made a sample ruby file and executed the tomdoc, but it blows out with the following error: