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. }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
I’ll first inspect the repository structure, language/build tooling, and current git state. Then I’ll locate the LSP completion implementation and relevant tests so I can reproduce the missing interface-member completion before changing source code.
pwd && git status --short && printf '\nTop-level files:\n' && ls -la && printf '\nLikely manifests:\n' && find . -maxdepth 2 -type f \( -name 'Cargo.toml' -o -name 'package.json' -o -name 'go.mod' -o -name 'pyproject.toml' \) -print - Assistant
The repository is a clean Rust workspace. I’ll now identify the LSP crate and search for completion handlers, member/method lookup, and interface type handling, along with any existing completion snapshots or unit tests.
find crates -maxdepth 2 -type f -name Cargo.toml -print printf '\nCompletion-related source/tests:\n' rg -n --glob '*.rs' --glob '*.lis' --glob '*.snap' 'completion|Completion|interface|Interface' crates | head -n 250 - Assistant
rgis not installed, so I’ll usefindand recursivegrepinstead. I’ll first list the LSP crate in full, then inspect all completion references across Rust sources.printf '%s\n' 'LSP files:' find crates/lsp -type f -maxdepth 5 -print | sort printf '\nCompletion references:\n' grep -RInE 'completion|Completion' crates --include='*.rs' --include='*.lis' --include='*.snap' | head -n 300 - Assistant
The relevant logic is concentrated in
crates/lsp/src/completion.rs, with dispatch inlib.rs. I’ll inspect both around instance completion/type resolution, plus the semantic definition/type structures they depend on, to determine whether interfaces are omitted during lookup or whether variable type resolution fails earlier.sed -n '1,360p' crates/lsp/src/completion.rs printf '\n--- completion dispatch ---\n' sed -n '1040,1195p' crates/lsp/src/lib.rs printf '\n--- semantic type/definition declarations ---\n' grep -RInE 'enum (DefinitionBody|Type|TypeKind)|struct (Definition|Interface)|DefinitionBody::Interface' crates/semantics/src crates/syntax/src --include='*.rs' | head -n 220 - Assistant
get_instance_completionsonly adds struct fields and separately registered value definitions named under the type. Interface methods are likely stored directly inDefinitionBody::Interface, which would explain the omission. I’ll inspect the exact interface representation, registration, inheritance support, and snapshot/store APIs before designing the fix.sed -n '1,210p' crates/syntax/src/program/definition.rs printf '\n--- interface registration ---\n' sed -n '330,440p' crates/semantics/src/checker/registration/methods.rs printf '\n--- semantic store interface helpers ---\n' sed -n '190,270p' crates/semantics/src/store.rs printf '\n--- interface usages/accessors ---\n' grep -RIn 'DefinitionBody::Interface' crates --include='*.rs' - Assistant
The root cause is now concrete: interface method definitions are registered with the
selfreceiver removed, whileget_instance_completionsonly accepts method definitions whose first parameter equalstype_id. Thus every interface method failsis_instance_method. A robust fix should read methods fromInterface.methodsdirectly, and should account for embedded parent interfaces and generic substitution if the semantic checker expects those methods to be available. I’ll inspect interface registration and method-resolution code to mirror the compiler’s behavior rather than implementing a one-off special case.sed -n '240,390p' crates/semantics/src/checker/registration/methods.rs sed -n '440,560p' crates/semantics/src/checker/registration/methods.rs printf '\n--- interface method resolution / parent traversal ---\n' grep -RInE 'parent_interfaces_of|\\.parents|\\.methods|get_interface\\(' crates/semantics/src --include='*.rs' | head -n 260 printf '\n--- workspace test organization ---\n' find crates/lsp tests -type f | sort | head -n 200 - Assistant
There is an existing LSP integration harness, so I’ll inspect its completion tests and project setup. I also want the full compiler helper that gathers inherited methods, plus
AnalysisSnapshotaccessors, to decide whether completion can recurse through definitions without adding dependencies.grep -nE 'completion|complete' tests/lsp.rs tests/lsp_harness.rs sed -n '530,590p' crates/semantics/src/checker/registration/methods.rs sed -n '1,220p' crates/lsp/src/snapshot.rs sed -n '1,180p' tests/lsp.rs - Assistant
I need to reproduce the reported behavior without modifying or adding repository tests. The simplest route is to drive the compiled LSP over JSON-RPC from a temporary Python script. I’ll inspect crate/package names and the test harness’s server startup and message framing, then build the appropriate binary and send initialize/open/completion requests for the exact issue sample.
cat crates/lsp/Cargo.toml cat Cargo.toml sed -n '1,380p' tests/lsp_harness.rs grep -RInE 'lsp|LanguageServer' crates/cli/src --include='*.rs' | head -n 100 - Assistant
- Assistant
The end-to-end reproduction returns
[], confirming the report. I’ll now inspect how dot-access typing distinguishes interface methods (including signatures without a bareself) and how generic parent substitution is performed. This will ensure completion semantics match actual callable methods and that inherited interface methods are represented accurately.sed -n '100,220p' crates/semantics/src/checker/infer/interface.rs sed -n '260,325p' crates/semantics/src/checker/infer/interface.rs grep -RInE 'DotAccess|method.*lookup|methods_of|method_type' crates/semantics/src/checker --include='*.rs' | head -n 240 sed -n '330,395p' crates/semantics/src/store.rs grep -nE 'substitut|replace.*var|apply.*type|instantiate' crates/syntax/src/types.rs | head -n 100 - Assistant
- Assistant
The change is localized and formatted. I’ll first compile the LSP crate, then rerun the same external end-to-end reproduction unchanged. This will catch API/type errors and verify that the exact reported completion now includes
example.cargo check -p lisette-lsp && cargo run --quiet --manifest-path /tmp/lisette-lsp-repro/Cargo.toml - Assistant
The exact reproduction is fixed: the response changed from
[]to["example"]. I’ll exercise edge cases with the same temporary client: multiple own methods and interface embedding, including duplicate inherited/overridden names. First I’ll confirm embedding syntax from existing language tests, then adapt only the external repro source and completion position.grep -RInE '^([[:space:]]*pub )?interface .*:' tests/spec --include='*.rs' --include='*.lis' | head -n 30 grep -RInE 'interface .*(\\+|:) ' tests/spec --include='*.rs' | head -n 30 - Assistant
The first search only found generic bounds, so I’ll inspect known inherited-interface tests and snapshots to identify the declaration syntax precisely before running the edge-case repro.
grep -RIn -C 8 'generic_interface_embedding\|inherited_methods\|interface embedding\|embeds' tests/spec --include='*.rs' | head -n 180 grep -RIn -C 5 'interface Parent\|interface Child\|interface Base' tests --include='*.rs' | head -n 180 - Assistant
I found the relevant declarations; I’ll inspect those small source blocks and then run the inherited-method completion case.
sed -n '2710,2755p' tests/spec/build/mod.rs sed -n '5305,5345p' tests/spec/build/mod.rs - Assistant
I’ll now run an embedded-interface case with both own and inherited methods. The recursion guard also covers invalid cyclic input defensively, while normal semantic validation prevents such cycles.
python3 - <<'PY' from pathlib import Path p = Path('/tmp/lisette-lsp-repro/src/main.rs') s = p.read_text() start = s.index(' let source = ') end = s.index('\n writer.send(', start) s = s[:start] + ''' let source = "interface Parent {\\n fn parent(self) -> int\\n}\\ninterface Child {\\n impl Parent\\n fn child(self) -> int\\n}\\nfn call(ex: Child) -> int {\\n ex.\\n}\\n";''' + s[end:] s = s.replace('"position":{"line":5,"character":5}', '"position":{"line":8,"character":5}') p.write_text(s) PY cargo run --quiet --manifest-path /tmp/lisette-lsp-repro/Cargo.toml - Assistant
Inherited completion works (
child,parent). The issue also mentions stdlib interfaces, so I’ll identify a prelude/stdlib interface and verify completion on a parameter of that type through the same end-to-end client. I’ll search source declarations and choose one with a simple, valid type annotation.grep -RIn -A8 -E '^pub interface ' prelude crates/stdlib/typedefs --include='*.lis' | head -n 100 - Assistant
I’ll test the Go stdlib
hash.Hashinterface, whose six methods are representative of generated stdlib interfaces. The expected labels includeBlockSize,Reset,Size,Sum, andWrite.python3 - <<'PY' from pathlib import Path p = Path('/tmp/lisette-lsp-repro/src/main.rs') s = p.read_text() start = s.index(' let source = ') end = s.index('\n writer.send(', start) s = s[:start] + ''' let source = "import \\\\"go:hash\\\\"\\nfn call(ex: hash.Hash) {\\n ex.\\n}\\n";''' + s[end:] s = s.replace('"position":{"line":8,"character":5}', '"position":{"line":2,"character":5}') p.write_text(s) PY cargo run --quiet --manifest-path /tmp/lisette-lsp-repro/Cargo.toml - Assistant
Stdlib interface completion also works and returns all
hash.Hashmethods. Next I’ll run the repository’s LSP integration suite. I’ll inspect the test package/target names first, then execute the relevant target; this avoids accidentally selecting a nonexistent Cargo target.cat tests/Cargo.toml cargo test -p lisette-tests --test lsp - Assistant
The manifest shows the package is named
tests, notlisette-tests; the failed command did not run any tests. I’ll rerun the correct LSP target now.cargo test -p tests --test lsp - Assistant
All 469 existing LSP integration tests pass. I’ll perform final static-quality checks (
clippywith warnings denied), inspect the complete diff/status for unintended files, and review the modified function once more for visibility/deduplication regressions.cargo clippy -p lisette-lsp -- -D warnings git status --short git diff --check git diff --stat sed -n '185,305p' crates/lsp/src/completion.rs
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.