-
-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Labels
Description
ruby-parse -e '
begin
foo
bar
rescue StandardError => e
baz
ensure
quux
end
'
(kwbegin
(ensure
(rescue
(begin <---------- A
(send nil :foo)
(send nil :bar))
(resbody
(array
(const nil :StandardError))
(lvasgn :e)
(send nil :baz)) nil)
(send nil :quux))) <---------- B
RescueNode.body returns the body of the begin...end block (marked A above). It has resbody_branches and branches to access the bodies of each rescue branch.
EnsureNode.body returns the body of the ensure branch (marked B above). It has currently no method to return the begin...end block, which may or may not be inside a rescue node.
I'd like to have an EnsureNode.body method that mirrors RescueNode.body (ie. returns the code before rescue/ensure), but the method name is already in use for something inconsistent.
- Would it be okay to rename
EnsureNode.body? I'd update rubocop/extensions to match once released. - If not, what could the method to return
Abe called onEnsureNode?