Skip to content
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

pipe autocomplete does not give suggestions #335

Closed
a-c-sreedhar-reddy opened this issue Jan 9, 2022 · 1 comment · Fixed by #342
Closed

pipe autocomplete does not give suggestions #335

a-c-sreedhar-reddy opened this issue Jan 9, 2022 · 1 comment · Fixed by #342

Comments

@a-c-sreedhar-reddy
Copy link
Contributor

a-c-sreedhar-reddy commented Jan 9, 2022

module Test = {
  type t = {name: int}
  let add = (a: t) => a.name + 1
}
let a: Test.t = {name: 4}
// a->

auto-complete does not suggest Test.add in the above example.

When I replace

 | {SharedTypes.item = Value typ} :: _ -> (

with

|  _ :: {SharedTypes.item = Value typ} :: _ -> (

here

This works, but i could not reason out why.

@a-c-sreedhar-reddy a-c-sreedhar-reddy changed the title Autocomplete does not work pipe autocomplete does not work Jan 9, 2022
@a-c-sreedhar-reddy a-c-sreedhar-reddy changed the title pipe autocomplete does not work pipe autocomplete does not give suggestions Jan 9, 2022
@cristianoc
Copy link
Collaborator

This is an interesting case.
While features such as jump to definition use the results of type checking (assuming the file is compiled), autocomplete cannot do that, but needs to understand the code being edited and make use of type checking results from the previous compilation.
In this case, there are two a's: the labeled argument to add, and the value declared at the end. This could be resolved in general by checking the id associated to a by the type checker, except we don't have such information. So in this case, autocomplete just picks the wrong a (the labeled arg), and no autocomplete suggestions are given.

Without replicating the entire scope checking mechanism of the compiler, there's no way to get completely accurate results. But, it should be possible to come up with a decent heuristic that gets it right most of the times.
In this case, such a heuristic could be: pick the latest a above the current cursor position. This would also take care of the other issue #336 which has analogous underlying cause.

cristianoc added a commit that referenced this issue Jan 19, 2022
…euristic to approximate the correct scope.

Fixes #335
Fixes #336
cristianoc added a commit that referenced this issue Jan 19, 2022
…euristic to approximate the correct scope.

Fixes #335
Fixes #336
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants