ISSUE DESCRIPTION LSP doesn't provide completion for interfaces Lisette version: 0.2.11…
- User
ISSUE DESCRIPTION
LSP doesn't provide completion for interfaces Lisette version: 0.2.11 IDE: VSCode and Zed
The LSP isn't providing completions for interfaces from either stdlib or user-defined.
interface Example { fn example(self, name: string) -> string } fn example_call(ex: Example) -> string { ex. }Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /lisette, current file: none) bash-$
Assistant
Let me explore the repository structure to understand the codebase.
Assistant
Let me understand the issue. The LSP doesn't provide completions for interfaces. Let me look at how completions are triggered and how the
detect_dot_contextworks. The issue is when you have a parameter typed as an interface, typingex.should give completions for the interface methods.Let me trace through the code. When the user types
ex., thedetect_dot_contextis called. Let me look at how completions are assembled.Assistant
Let me look at how completions are handled in the snapshot, particularly where
detect_dot_contextandget_instance_completionsare called.Assistant
Now let me find where completion is actually assembled/handled (the entry point):
Assistant
Let me look at the Definition types, particularly Interface:
Assistant
Now let me understand how interface methods are stored in definitions. Let me search how interfaces are processed in semantics:
Assistant
Let me look at the existing tests for completion:
Assistant
Let me look at the test harness to understand how to write a reproduction:
Assistant
Let me look at the interface stress test to understand the interface syntax:
Assistant
Now let me write a reproduction test. Let me create a temporary test file:
Assistant
Now let me check the
completion_labelsfunction and thecompletionmethod to understand the column. The source is:interface Example { fn example(self, name: string) -> string } fn example_call(ex: Example) -> string { ex. }Line 0:
interface Example {Line 1:fn example(self, name: string) -> stringLine 2:}Line 3:fn example_call(ex: Example) -> string {Line 4:ex.Line 5:}So position (4, 4) is after
ex.. Good. Let me run the test.Assistant
The test file needs to be in the right place. Let me check Cargo.toml for test targets. The available test targets are e2e_suite, lsp, suite. The
lsp.rstest is at/lisette/tests/lsp.rs. So my repro file should work as a test target if it's auto-discovered... but it says only lsp, suite, e2e_suite. Maybe there's a [[test]] configuration. Let me check.Assistant
There's a separate
testspackage. Let me check it:Assistant
I'll add a test entry to Cargo.toml temporarily:
Assistant
Let me look at the position_to_offset and find_expression_at to understand cursor positioning:
Assistant
Let me check the existing test for empty-member dot completion (cursor right after the dot):
Assistant
Let me update my test to position the cursor right after the dot (column 5):
Assistant
The labels are now empty
[], confirmingdetect_dot_contextreturnsInstancebutget_instance_completionsreturns nothing. This confirms my hypothesis: interface methods have their receiver stripped during registration, sois_instance_methodreturns false.Let me look at how interface method calls are resolved to understand inherited methods:
Assistant
Let me look at the prelude to find stdlib interfaces, and check how
type_nameis imported in completion.rs:Assistant
Now I understand the issue fully. The stdlib
errorinterface has a methodError()with noselfreceiver, and user-defined interface methods have theirselfreceiver stripped during registration. In both cases,is_instance_methodreturns false, so no completions are produced. Let me implement the fix:Assistant
Now let me implement the fix. I'll edit
get_instance_completionsto handle interfaces (including inherited methods from parent interfaces):Assistant
Now let me build and run my reproduction test:
Assistant
The reproduction test passes. Now let me test more edge cases - inherited interface methods, stdlib
errorinterface, and the type-level dot case:Assistant
I miscounted the line numbers. Let me fix the cursor positions:
Assistant
Inherited methods aren't showing. Let me investigate how parent interface types are stored. Let me check
convert_to_type:Assistant
So
convert_to_typeresolves the type name viaresolve_type_with_aritywhich returns the qualified name. So the parent type should be a Nominal with the qualified idmodule.Base. Sotype_nameshould returnmodule.Base.Wait, but maybe the issue is that the parent is stored as the resolved type, which for an interface... Let me check what
resolve_type_with_arityreturns and what the final Type is. Let me continue reading.Assistant
Let me check whether the parent interface syntax is parsed correctly. Let me look at the parser for interfaces:
Assistant
The parent interface syntax uses
impl Baseinside the body, notinterface Derived: Base. Let me check existing usage:Assistant
The parent interface syntax is
impl Baseinside the body. Let me fix my test:Assistant
The python replace didn't match. Let me view and edit the test directly:
Assistant
All four tests pass, including inherited interface methods and the stdlib
errorinterface. Now let me run the full existing LSP test suite to make sure nothing is broken:Assistant
All 469 LSP tests pass. Let me also run the broader test suites that might be affected:
Assistant
Many failures in
suite. Let me check if these are pre-existing (unrelated to my change) by stashing my change and re-running a sample:Assistant
The 1513 failures are pre-existing (same count without my change) — likely environment-related (Go toolchain/bindgen). Let me restore my changes:
Assistant
The suite failures are pre-existing snapshot mismatches (environment-dependent Go/bindgen output producing
.snap.newfiles), unrelated to my change. Let me clean up these test artifacts and verify the UI/lint tests (which involve interfaces) pass:Assistant
The UI/lint tests (which exercise interfaces) all pass. Now let me clean up my temporary repro test file and the Cargo.toml change, then review the final diff:
Assistant
Let me fix the double blank line and run rustfmt to ensure clean formatting:
Assistant
rustfmt fixed the formatting. Let me rebuild and re-run the LSP test suite to confirm everything passes after formatting:
Assistant
Let me do a final end-to-end verification with the reproduction test (re-create, run, then remove):
Assistant
All three edge cases pass. Now let me clean up the temporary test artifacts and verify the final state:
Assistant
The only remaining change is in
crates/lsp/src/completion.rs. Let me do a final review of the complete modified function:Assistant
The fix looks complete and correct. Let me do a final build check to ensure no warnings:
Assistant
The build is clean with no warnings. Let me submit the solution.
Summary
Issue: The LSP didn't provide completions for interfaces (neither stdlib nor user-defined) when typing
ex.on a variable typed as an interface.Root cause: In
crates/lsp/src/completion.rs,get_instance_completionsfinds methods by scanningDefinition::Valueentries whose qualified name starts with{type_id}., and filters them withis_instance_method. That helper checks whether the method's first parameter type matches the receiver type. However, interface methods are registered with theirselfreceiver parameter stripped (seepopulate_interfaceincrates/semantics/src/checker/registration/methods.rs), and some interface methods (like stdliberror.Error()) have no receiver at all. Sois_instance_methodalways returnedfalsefor interface methods, producing zero completions.Fix: Added an interface-specific branch in
get_instance_completions. Whentype_idresolves to anInterfacedefinition, it collects the interface's methods directly (subject to visibility, without theis_instance_methodcheck) via a newcollect_interface_methodshelper that also recursively walks parent interfaces (impl Parentembedding) to include inherited methods, with cycle protection and de-duplication.Checklist
- Reproduced the error: Created a temporary LSP test mirroring the issue (
ex.on anExampleinterface param) — confirmed it returned empty/global completions before the fix. - Confirmed the fix resolves the error: The same test passes after the fix; also verified the stdlib
errorinterface (err.→Error) and inherited interface methods (DerivedimplBase→ bothderived_methodandbase_method). - Edge cases considered: receiver-stripped methods, methods with no receiver (stdlib
error), inherited methods via parent interfaces, cycle protection for recursive parent chains, de-duplication, visibility rules, and ensuring struct/enum completions still work unchanged. - Existing tests run: All 469 LSP tests pass; UI/lint tests (256, including interface-related ones) pass. The
suitefailures are pre-existing environment-dependent Go/bindgen snapshot mismatches (identical 1513 count with and without my change), unrelated to this LSP-only edit.
- Reproduced the error: Created a temporary LSP test mirroring the issue (
Assistant
The user is telling me that I need to submit my changes using the submit command. Let me do that now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →