diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-05 08:14:06 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:43 +0000 |
| commit | 17111084d4f01840db3d0c76c250ff4430be73bf (patch) | |
| tree | a33250417554bb512f20277168cd665fa9f22910 | |
| parent | 524e93b84e1a08e5f8dabaad123cecd6b85cf82a (diff) | |
[ruby/prism] Implement endless methods for ripper translation
https://github.com/ruby/prism/commit/6611820b7b
| -rw-r--r-- | lib/prism/translation/ripper.rb | 29 | ||||
| -rw-r--r-- | test/prism/ripper_test.rb | 5 |
2 files changed, 18 insertions, 16 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index 5f6200cbe8..e50aec1d15 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -842,19 +842,26 @@ module Prism end bodystmt = - case node.body - when nil - bounds(node.location) - on_bodystmt(visit_statements_node_body([nil]), nil, nil, nil) - when StatementsNode - body = visit(node.body) + if node.equal_loc.nil? + case node.body + when nil + bounds(node.location) + on_bodystmt(visit_statements_node_body([nil]), nil, nil, nil) + when StatementsNode + body = visit(node.body) + + bounds(node.body.location) + on_bodystmt(body, nil, nil, nil) + when BeginNode + visit_begin_node_clauses(node.body) + else + raise + end + else + body = visit(node.body.body.first) bounds(node.body.location) on_bodystmt(body, nil, nil, nil) - when BeginNode - visit_begin_node_clauses(node.body) - else - raise end on_def(name, parameters, bodystmt) @@ -982,7 +989,7 @@ module Prism # def foo(...); bar(...); end # ^^^ def visit_forwarding_arguments_node(node) - raise NoMethodError, __method__ + end # def foo(...); end diff --git a/test/prism/ripper_test.rb b/test/prism/ripper_test.rb index 9f6a8a3c9f..48dab05d73 100644 --- a/test/prism/ripper_test.rb +++ b/test/prism/ripper_test.rb @@ -380,15 +380,10 @@ module Prism seattlerb/class_comments.txt seattlerb/defn_arg_forward_args.txt seattlerb/defn_args_forward_args.txt - seattlerb/defn_endless_command.txt - seattlerb/defn_endless_command_rescue.txt seattlerb/defn_forward_args.txt seattlerb/defn_forward_args__no_parens.txt seattlerb/defn_kwarg_lvar.txt - seattlerb/defn_oneliner.txt seattlerb/defn_oneliner_eq2.txt - seattlerb/defn_oneliner_noargs.txt - seattlerb/defn_oneliner_noargs_parentheses.txt seattlerb/defn_oneliner_rescue.txt seattlerb/defn_unary_not.txt seattlerb/defns_reserved.txt |
