summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-03-05 17:43:50 -0500
committergit <svn-admin@ruby-lang.org>2024-03-06 16:42:47 +0000
commit78fe61c95fecf8e7964337a067908976d9d4bfca (patch)
tree2b89ee32446dface2e47050b90aaa2d811f9694c
parentc2d6bcc81a827786c2cffefbac0840cc1c9b42d5 (diff)
[ruby/prism] Implement fields for ripper translation
https://github.com/ruby/prism/commit/90f8b33fad
-rw-r--r--lib/prism/translation/ripper.rb44
-rw-r--r--test/prism/ripper_test.rb5
2 files changed, 26 insertions, 23 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb
index 5addc69318..ada44b81d6 100644
--- a/lib/prism/translation/ripper.rb
+++ b/lib/prism/translation/ripper.rb
@@ -556,29 +556,37 @@ module Prism
bounds(node.message_loc)
message = visit_token(node.message)
- arguments, block = visit_call_node_arguments(node.arguments, node.block)
- call =
- if node.opening_loc.nil?
- bounds(node.location)
+ if node.name.end_with?("=") && !node.message.end_with?("=") && !node.arguments.nil? && node.block.nil?
+ bounds(node.arguments.location)
+ value = visit(node.arguments.arguments.first)
- if !arguments || arguments.empty?
- on_call(receiver, call_operator, message)
+ bounds(node.location)
+ on_assign(on_field(receiver, call_operator, message), value)
+ else
+ arguments, block = visit_call_node_arguments(node.arguments, node.block)
+ call =
+ if node.opening_loc.nil?
+ bounds(node.location)
+
+ if !arguments || arguments.empty?
+ on_call(receiver, call_operator, message)
+ else
+ on_command_call(receiver, call_operator, message, arguments)
+ end
else
- on_command_call(receiver, call_operator, message, arguments)
+ bounds(node.opening_loc)
+ arguments = on_arg_paren(arguments)
+
+ bounds(node.location)
+ on_method_add_arg(on_call(receiver, call_operator, message), arguments)
end
- else
- bounds(node.opening_loc)
- arguments = on_arg_paren(arguments)
- bounds(node.location)
- on_method_add_arg(on_call(receiver, call_operator, message), arguments)
+ if block.nil?
+ call
+ else
+ bounds(node.block.location)
+ on_method_add_block(call, block)
end
-
- if block.nil?
- call
- else
- bounds(node.block.location)
- on_method_add_block(call, block)
end
end
end
diff --git a/test/prism/ripper_test.rb b/test/prism/ripper_test.rb
index 37e6e764e4..a58b52b5f7 100644
--- a/test/prism/ripper_test.rb
+++ b/test/prism/ripper_test.rb
@@ -21,7 +21,6 @@ module Prism
dash_heredocs.txt
dos_endings.txt
embdoc_no_newline_at_end.txt
- emoji_method_calls.txt
endless_methods.txt
global_variables.txt
hashes.txt
@@ -49,7 +48,6 @@ module Prism
seattlerb/TestRubyParserShared.txt
seattlerb/array_lits_trailing_calls.txt
seattlerb/attr_asgn_colon_id.txt
- seattlerb/attrasgn_primary_dot_constant.txt
seattlerb/begin_rescue_else_ensure_bodies.txt
seattlerb/begin_rescue_else_ensure_no_bodies.txt
seattlerb/block_break.txt
@@ -209,8 +207,6 @@ module Prism
seattlerb/rescue_in_block.txt
seattlerb/rescue_parens.txt
seattlerb/return_call_assocs.txt
- seattlerb/safe_attrasgn.txt
- seattlerb/safe_attrasgn_constant.txt
seattlerb/safe_call_dot_parens.txt
seattlerb/slashy_newlines_within_string.txt
seattlerb/stabby_arg_no_paren.txt
@@ -373,7 +369,6 @@ module Prism
whitequark/ruby_bug_14690.txt
whitequark/ruby_bug_15789.txt
whitequark/send_attr_asgn.txt
- whitequark/send_attr_asgn_conditional.txt
whitequark/send_block_chain_cmd.txt
whitequark/send_call.txt
whitequark/send_index_cmd.txt