-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Faulty code: forbid read of undeclared variables #13238
Faulty code: forbid read of undeclared variables #13238
Conversation
the failing tests are not an issue that much: mainly codesnippet and other compiler tests to update. Numbers are more interesting: in the pristine bootstrapped image, 536 methods remain with undeclared variable reads at compile time. For the first case, there are no real incentives (only warning in the Jenkins log) to have nice dependencies, so it could have been worse. Another possibility is to recompile these 536 methods. |
Oh, the important part I forgot to write in the previous message: on the first try, bootstrap passed and the very large majority of tests succeeded (above 99.7%). 🎉 I also played (graphically) with the produced image (to inspect some methods) and everything went fine. After a good night of sleep, I think it's the way forward. We are still very early in Pharo12 (Pharo11 isn't even released!) and it will be easy to backtrack (totally or in a milder form) if for some reason we break too many (or too important) clients. |
… VariableNotDeclared exception
Some updates:
For this last point, I need to explain more: |
All green on the second try! 🎉 I think it's good for me, other improvements can be done in other PR. |
There is now a conflict |
I think I will wait for approves (or discussion) before solving the conflict |
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.
- it is nice how now the debugger opens when the Undeclared is accessed.
- I think we can remove the hack in visitVariableNode: and even clean up UndefinedObject>>#doesNotUnderstand:, as the hack in the end was just for that: enable test first development even if there is a send to a Undeclared, which was just a DNU and did not allow to create a class easily
I solved the merge conflicts, I blinked, and now there are more merge conflicts 😭 |
merge done, CI running |
test still OK! |
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.
Everything seems good to me.
With the read resumable it should be fine for most things that would have bugged me otherwise :)
This is the read pendent of #13201
Unlike the write case, I'm still not sure if that is the right move, as
nil
is a consistent answer to a buggy read.Almost all the time, reading an undeclared variable is a bug, but nil is nevertheless consistent.
While some dynamic languages have a YOLO approach, it seems that Pharo tries to encourage some control and fail-fast philosophy. For instance, there are a bunch of runtime errors in Kernel-Exceptions that could have defaulted to be a silent nil.
Maybe this requires more thinking.
However, I did miss in the previous experiment (#13189) the opportunity to check senders because I did not use a distinctive selector. So, at least, let's check senders this time!