Actions
Bug #17621
closedRipper can call on_parse_error multiple times for syntax error. Is this correct?
Description
Here's an example subclass of Ripper:
class MyRipperSubclass < Ripper
def on_parse_error(msg)
@count ||= 0
@count += 1
puts [count: @count, msg: msg]
end
end
source = <<~EOM
module Hey
class Foo
def initialize
[1,2,3
end
def call
end
end
end
EOM
MyRipperSubclass.new(source).parse
The source it's parsing has a syntax error, so I would only expect one parse error. However, when you execute this code, you see two:
MyRipperSubclass.new(source).parse
# => {:count=>1, :msg=>"syntax error, unexpected `end', expecting ']'"}
# => {:count=>2, :msg=>"syntax error, unexpected end-of-input, expecting `end'"}
Is this a bug, or is this expected? If this is expected, can you give me more context? Is there an upper bound to the number of parse errors a document can generate? Is the order guaranteed?
Actions
Like0
Like0Like0Like0