-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
Remove addNodeLast from update chnages #18016
base: Pharo13
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
With Balsa we wrote a little visitor fully tested that adds the last node correctly.
|
Sure @Ducasse I researched the whole codebase I could not find any visitor that adds the last node which you mentioned. If you could help me finding where adding last node visitor is, I could definitely try this issue. |
parseTree body lastIsReturn | ||
ifTrue: [ | ||
parseTree body | ||
addNode: newNode | ||
before: parseTree body statements last ] | ||
ifFalse: [ parseTree body addNode: newNode ]. | ||
parseTree ]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a bit buggy?
I know you're just inlining the method here, but my point is:
- sometimes it adds the node as the last one
- sometimes as the one before the last one
I don't see how this could work in general, there are probably cases where this produces broken code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thnx @guillep
But according to this current implementation first it checks if the last statement is a return statement or not
If it is, only then it adds the new node one before the last one else it adds new node at the end ( Don't you think this is correct behaviour )
Yeah there could be case where this might lead to unexpected behaviour
In case if we find that last statement is not a return statement then it will add the node in last which could lead to some issue
For example:
calculateSum [
| a b result |
a := 5.
b := 10.
result := a + b.
result
]
Here it returns result
implicitly & if we use this logic to add a new node let's say ( a * b ) then it will be added to last according to logic & the method becomes this
calculateSum [
| a b result |
a := 5.
b := 10.
result := a + b.
result.
a * b
]
Now in this case it will start returning different value.
But for this what we can do is , here we can use OCReturnNodeAdderVisitor
to first wrap the node as return & then add new node one before the last.
But there might be some methods which intentionally does not want to return any value in that case we are forcing to return value so maybe again we will have to come up with some logic to find whether it has implicit return or not then wotk out according to that. I just wanted to tell the idea I came up with .
Am I making any sense here or this is completely wrong approach ?
If you have some time could you give me some example where the already implemented logic would produces broken code as it would help me understand the issue better ?
Sorry this became a very long message
I think the original issue meant to remove this behavior entirely Probably this means analysing in if there is not a bug there, propose some tests, do a bit of redesign... |
Guille you are right I forgot what I wanted. |
So you want me to replace the adding node logic using |
Sorry I was confusing. |
I'm dead coming back from a long trip so my brain is out of order. I will have to take time to reply to you. |
Yeah I get this now. |
For sure @Ducasse I am okay with it. |
Fixes: #17847
addNodeLast
fromRBAddSubtreeTransformation
& updated its logicaddNodeLast
method fromOCSequenceNode