Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3446,12 +3446,12 @@ def bounds(location)

# :stopdoc:
def _dispatch_0; end
def _dispatch_1(_); end
def _dispatch_2(_, _); end
def _dispatch_3(_, _, _); end
def _dispatch_4(_, _, _, _); end
def _dispatch_5(_, _, _, _, _); end
def _dispatch_7(_, _, _, _, _, _, _); end
def _dispatch_1(arg); arg end
def _dispatch_2(arg, _); arg end
def _dispatch_3(arg, _, _); arg end
def _dispatch_4(arg, _, _, _); arg end
def _dispatch_5(arg, _, _, _, _); arg end
def _dispatch_7(arg, _, _, _, _, _, _); arg end
Comment on lines 3448 to +3454
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we didn't/don't just copy that part from upstream.
Maybe the unused variables cause warnings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice. I was mostly just guessing but this makes it pretty clear.

# :startdoc:

#
Expand Down
34 changes: 34 additions & 0 deletions test/prism/ruby/ripper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,40 @@ class RipperTest < TestCase
define_method("#{fixture.test_name}_lex") { assert_ripper_lex(fixture.read) }
end

module Events
attr_reader :events

def initialize(...)
super
@events = []
end

Prism::Translation::Ripper::PARSER_EVENTS.each do |event|
define_method(:"on_#{event}") do |*args|
@events << [event, *args]
super(*args)
end
end
end

class RipperEvents < Ripper
include Events
end

class PrismEvents < Translation::Ripper
include Events
end

def test_events
source = "1 rescue 2"
ripper = RipperEvents.new(source)
prism = PrismEvents.new(source)
ripper.parse
prism.parse
# This makes sure that the content is the same. Ordering is not correct for now.
assert_equal(ripper.events.sort, prism.events.sort)
end

def test_lexer
lexer = Translation::Ripper::Lexer.new("foo")
expected = [[1, 0], :on_ident, "foo", Translation::Ripper::EXPR_CMDARG]
Expand Down