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

Prefer exact matches when guessing types #3112

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Jan 30, 2025

Motivation

I noticed we weren't guessing the correct types even in situations where I expected us to. The issue turns out to be not preferring exact matches.

For example, where type is used in the LSP itself, we ended up guessing ParseResultType from Prism because that was the first constant ending with Type that we found.

I think we can improve our accuracy by preferring exact matches over partial ones.

Implementation

Started looking for exact matches first, falling back to our original partial matches.

Automated Tests

Added a test that reproduces the scenario.

@vinistock vinistock self-assigned this Jan 30, 2025
@vinistock vinistock added server This pull request should be included in the server gem's release notes bugfix This PR will fix an existing bug labels Jan 30, 2025 — with Graphite App
Copy link
Member Author


How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock requested review from andyw8 and st0012 January 30, 2025 14:26
@vinistock vinistock marked this pull request as ready for review January 30, 2025 14:28
@vinistock vinistock requested a review from a team as a code owner January 30, 2025 14:28
@vinistock vinistock added the graphite-merge Ship this PR using Graphite's merge queue label Jan 30, 2025
Copy link
Member Author

vinistock commented Jan 30, 2025

Merge activity

  • Jan 30, 10:12 AM EST: The merge label 'graphite-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jan 30, 10:17 AM EST: A user added this pull request to the Graphite merge queue.
  • Jan 30, 10:44 AM EST: A user merged this pull request with the Graphite merge queue.

### Motivation

I noticed we weren't guessing the correct types even in situations where I expected us to. The issue turns out to be not preferring exact matches.

For example, where `type` is used in the LSP itself, we ended up guessing `ParseResultType` from Prism because that was the first constant ending with `Type` that we found.

I think we can improve our accuracy by preferring exact matches over partial ones.

### Implementation

Started looking for exact matches first, falling back to our original partial matches.

### Automated Tests

Added a test that reproduces the scenario.
@vinistock vinistock force-pushed the 01-30-prefer_exact_matches_when_guessing_types branch from cf8adb2 to 56aa676 Compare January 30, 2025 15:16
@graphite-app graphite-app bot merged commit 56aa676 into main Jan 30, 2025
44 checks passed
@graphite-app graphite-app bot deleted the 01-30-prefer_exact_matches_when_guessing_types branch January 30, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug graphite-merge Ship this PR using Graphite's merge queue server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants