Skip to content

Commit

Permalink
Disallow keywords as method names in ripper translation
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Mar 6, 2024
1 parent 4e77334 commit dc74428
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def visit_call_node(node)
on_binary(receiver, node.name, value)
else
bounds(node.message_loc)
message = visit_token(node.message)
message = visit_token(node.message, false)

if node.variable_call?
on_vcall(message)
Expand Down Expand Up @@ -666,7 +666,7 @@ def visit_call_node(node)
:call
else
bounds(node.message_loc)
visit_token(node.message)
visit_token(node.message, false)
end

if node.name.end_with?("=") && !node.message.end_with?("=") && !node.arguments.nil? && node.block.nil?
Expand Down Expand Up @@ -2761,13 +2761,13 @@ def void_stmt?(left, right)

# Visit the string content of a particular node. This method is used to
# split into the various token types.
def visit_token(token)
def visit_token(token, allow_keywords = true)
case token
when "."
on_period(token)
when "`"
on_backtick(token)
when *KEYWORDS
when *(allow_keywords ? KEYWORDS : [])
on_kw(token)
when /^_/
on_ident(token)
Expand Down
2 changes: 0 additions & 2 deletions test/prism/ripper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class RipperTest < TestCase

skips = incorrect | %w[
arrays.txt
case.txt
constants.txt
dos_endings.txt
embdoc_no_newline_at_end.txt
heredocs_leading_whitespace.txt
Expand Down

0 comments on commit dc74428

Please sign in to comment.