diff options
author | Kevin Newton <kddnewton@gmail.com> | 2024-03-06 00:38:02 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:58 +0000 |
commit | f96ce41ac88267a6dce2d13f6f0400f2265476a9 (patch) | |
tree | 04c32549e8b2e5eacbbbb85110997a6d37fe4c9d | |
parent | 14877e737bcf38477d783a7d5f0dda29becc0a5b (diff) |
[ruby/prism] Disallow keywords as method names in ripper translation
https://github.com/ruby/prism/commit/dc74428e2e
-rw-r--r-- | lib/prism/translation/ripper.rb | 8 | ||||
-rw-r--r-- | test/prism/ripper_test.rb | 2 |
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index f9cd6d3ada..be4032de8d 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -629,7 +629,7 @@ module Prism 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) @@ -666,7 +666,7 @@ module Prism :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? @@ -2761,13 +2761,13 @@ module Prism # 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) diff --git a/test/prism/ripper_test.rb b/test/prism/ripper_test.rb index 87cac7569f..076bcef085 100644 --- a/test/prism/ripper_test.rb +++ b/test/prism/ripper_test.rb @@ -26,8 +26,6 @@ module Prism skips = incorrect | %w[ arrays.txt - case.txt - constants.txt dos_endings.txt embdoc_no_newline_at_end.txt heredocs_leading_whitespace.txt |