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
Immediate, Rust-level type hints #3597
Comments
This is along the lines of what I wanted to do initially, but one reason I switched was that there was a desire to not load/ execute user code in the LSP. This seems like a good idea if we can deal with that. The other reason I switched to using the REPL was so we could use variables and redefined function from the REPL but with the alternative approach maybe we could continue to support that. Or at worst we don't but you can just run Another concern would be if Cthulhu would be fast enough, iirc the main reasons why it's slow is pretty printing types and compilation. Presumably if we're rerunning Cthulhu a lot we could ensure it's caching things appropriately so that it is able to be fast. Also, I'm not sure a comment in a file is the best place for this to be in the long term but we can of course change it at some point. Whilst Cthulhu only supports descending in a single file for now, if it did support multiple files it could get tricky to know which descend to run if there are multiple or to know where which file the descend comment is in. |
Good points! I moved this post to discourse btw: https://discourse.julialang.org/t/how-can-we-get-rust-level-feedback-on-type-stability/113497, maybe copy your comment there so others can see it? |
@Zentrik @pfitzseb I am thinking about the best way to get continual feedback with more detailed type hints in VSCode. Similar to how it is done with rust-analyzer.
Since Julia is very dynamic, this is obviously a bit trickier. Right now the mechanism for this is to connect a REPL, and run Cthulhu descend (thanks to @Zentrik’s PR and @timholy’s Cthulhu).
This is awesome but I am wondering if we can do even better. I want type information to automatically show up while I am typing out the function, so I can immediately spot type indtability, rather than needing to manually descend to find it.
Here’s one idea: could we have a special comment that tells Julia LSP to run Cthulhu for the function with a given input?
For example:
This "descend" would tell the Julia language server to continually run
Cthulhu.descend(foo, ([1, 2, 3],))
whenever the code is changed. (Or just@code_warntype
, but I feel like multiple levels could be useful)In the future you could also specify multiple
descend
. In VSCode I believe there is the ability to cycle between code warnings for a given function (?) which would let you quickly switch between seeing the warnings for different example inputs.The descend could also be more complex to allow different input types. For example,
I think the comments are the right place to put this because this is where you control linters and formatters.
Edit: I'm going to cross-post this on the discourse as I think wider input might be useful too!
The text was updated successfully, but these errors were encountered: