-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Mass-adding type restrictions (def foo() : Bar
)
#10575
Comments
Launched phase 2, adding Nil return type restrictions where the methods currently actually don't return nil but weren't meant to have a return value. |
Keep'em coming! ❤️ |
I milestoned the entire first batch of PRs. I think they're ready to be merged. The changes are rather big in terms of affected code. But there are presumably no semantic changes. |
Nice. 5 more conflicts appeared. |
The entire first batch has been merged. |
About the second batch: These are technically breaking changes because they alter the return value from something that is not |
I'd like to test the incoming changes from the second batch with test-ecosystem before merging them to master. Should wait after 1.1.1 is released though, to avoid congestion on test-ecosystem CI. |
I ran test-ecosystem on all five outstanding PRs and they look good 👍 That doesn't mean it won't break anything else, but it's a encouraging sign. Adding a return type restriction of So I think we should go on and merge the Change nonsense return types to Nil PRs. |
Gotta love more return types ❤️ Thanks @oprypin @straight-shoota 🙏 |
The second batch has been merged. Thanks @oprypin |
I'm not sure if there's anything left here. Can we close this? |
It could be used for tracking of something in the future, but right now indeed it's best to close it. Thanks |
I have developed a semi-automatic workflow to insert type restrictions into Crystal code, and I plan to apply it to the Crystal standard library. The main purpose is to make documentation better. It also guards against some accidental incompatible changes.
The first phase will be only adding method return type restrictions. It's about 1400 annotations added.
Links (I don't guarantee that the links won't break):
The implementation just needs to be fed real usages of the code, and it looks at all the methods that the compiler resolves while compiling the code, and if the method resolves to the same type in every situation, it figures that maybe it's good to add that type as a type restriction. It's super hacky and super unreliable so I filter and fix the results myself.
But I hope that the methods that this automation suggests to restrict are also safe places to make those changes; I'm not coming up with my own ideas, and if I did, I might miss the fact that I'm changing the actual type (e.g. setting it to Nil but it really isn't Nil and someone relied on that).
Semi-related to #4864, mainly because the implementation is based on the patch posted to the issue
The text was updated successfully, but these errors were encountered: