-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Foo.Bar.baz<tab> – deep tab completion #10091
Comments
we should be able to utilize |
I should point out that I now can't reproduce the first part of this issue, so it may have been due to odd REPL state. The broader question of what to do when the LHS of a tab completion requires evaluation remains. When type inference can tell us the type of the LHS, then we can compute the type without even needing to evaluate. When the expression is effect free, then we can evaluate it safely. I guess adding those two will cover a lot of cases, so we should probably start there. |
When a tab completion would require evaluation of unverified code, we should just give up and don't complete anything. Inference and effect free will likely catch most situations, and if we are to go further, we'll need more analysis to ensure that the code will not print anything nor change global state (unless it is for logging purposes?). There might be a small number of cases where you can improve with more analysis, but basically I think we're back to the |
Also, even a pure function can take some time to compute, e.g. |
Or just stop at type inference, which is well bounded in time. If you can't type infer something, my impression is that it's unlikely that you can tell that it has no side-effects. |
You might almost want to start with an effect-free argument evaluation pass (to handle non-const) then do a typeinf step True though that effect-free (aka pure) doesn't fully imply fast. But currently effect-free does not accept branches, so that's ok |
Can someone give me a hint on how to do type inference on an expression to get the return type? Then I would give a shot at implementing it into the REPL to close #6338. I know this is a simple example, but how can I make type interference return the return type of the following expression?
|
I'm only just learning my way around I put some comments about |
I have made a little progress, by looking at
If there is a way of obtain a list of the global variables in the anonymous function, then I could supply the variable as argument in the function as: |
Presumably you need to get those into the "environment" (see variables named |
PR #15652 fix this issue, when it is merged. |
Use inference in dot completion FIX #10091.
We don't generally do tab completion when the thing to the left of the dot preceding the tab is more complicated than a name, since in the general case that would require evaluation of code in order to get the object to lookup names on. In the case where
Foo
is a module, however, evaluatingFoo.Bar
can't have any side-effects, so it would be safe to callnames(Foo.Bar)
in order to completebaz
.As a more general question, do we want to evaluate expressions to the left of dots when tab is pressed in order to do more general tab completion? It seems fairly unlikely that this would cause problems very often. This has come up a couple of times recently.
The text was updated successfully, but these errors were encountered: