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

Explore simple type flow analysis #2421

Closed
vinistock opened this issue Aug 9, 2024 · 1 comment
Closed

Explore simple type flow analysis #2421

vinistock opened this issue Aug 9, 2024 · 1 comment
Labels
enhancement New feature or request pinned This issue or pull request is pinned and won't be marked as stale server This pull request should be included in the server gem's release notes

Comments

@vinistock
Copy link
Member

By analyzing the flow of types in a program, we may be able to improve the accuracy for definition, hover, completion and signature help.

For example, understanding the type stored in a variable

something = Foo.new
something #=> something is an instance of Foo here

However, the Ruby LSP doesn't require a type system to provide features. We may discover that investing in type flow analysis without a type system actually doesn't provide much benefit (because most things would end up being untyped anyway).

Explore implementing simple type flow analysis:

  • Estimate the percentage of types we could understand better without a type system. This is limited to types discoverable without annotations:
    • Literals
    • Object instantiations (Object.new) only when self.new or self.allocate are not overridden
  • Investigate the phases to flow types in the analysis. Do we need to implement a CFG? Are there other options? Trade offs?

The output of this task is either the implemented flow analysis algorithm or an explanation of why it's not worth it without a type system.

@vinistock vinistock added enhancement New feature or request pinned This issue or pull request is pinned and won't be marked as stale server This pull request should be included in the server gem's release notes labels Aug 9, 2024
@vinistock
Copy link
Member Author

We have explored this and came to the conclusion that, without type annotations, the increase in accuracy for resolutions would be minimal.

At the same time, there's no such thing as "simple" flow analysis, as even the simplest snippets of Ruby code will require a considerable amount of infrastructure to properly type check and at least the basics of a type system to represent.

Therefore, we decided to not move forward with this effort at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned This issue or pull request is pinned and won't be marked as stale server This pull request should be included in the server gem's release notes
Projects
None yet
Development

No branches or pull requests

1 participant