-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistency between RescueNode
and EnsureNode
#334
Comments
Interesting. I agree it is not ideal. Just to be clear: you are proposing that |
Yes. I'm proposing that the body in all cases be the same, whether there's a rescue node or not. That will allow I've already added It'd also mean we'd need a new name for the current |
|
I actually would rather not use an array because that won't have location information and will be harder to work with IMO. If the body is multiple lines and wrapped in an ensure or a rescue, a begin node is added. I'm assuming none is added for |
Right. So "EnsureNode#body, RescueNode#body and (eventually) KeywordBeginNode#body to all be consistent." is not accurate in that sense, the first two would always return a node (possible a BeginNode), but the latter would always return an array of Nodes, correct? |
I'd rather not return an array in |
Ah, yes, I misunderstood. You are right, this is the way. So I agree with the program. Let's merge |
RescueNode.body
returns the body of thebegin...end
block (markedA
above). It hasresbody_branches
andbranches
to access the bodies of eachrescue
branch.EnsureNode.body
returns the body of theensure
branch (markedB
above). It has currently no method to return thebegin...end
block, which may or may not be inside arescue
node.I'd like to have an
EnsureNode.body
method that mirrorsRescueNode.body
(ie. returns the code before rescue/ensure), but the method name is already in use for something inconsistent.EnsureNode.body
? I'd update rubocop/extensions to match once released.A
be called onEnsureNode
?The text was updated successfully, but these errors were encountered: