Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION LSP doesn't provide completion for interfaces Lisette version: 0.2.11…

  1. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. GLM Assistant

    Let me explore the repository structure to understand the codebase.

  3. GLM 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_context works. The issue is when you have a parameter typed as an interface, typing ex. should give completions for the interface methods.

    Let me trace through the code. When the user types ex., the detect_dot_context is called. Let me look at how completions are assembled.

  4. GLM Assistant

    Let me look at how completions are handled in the snapshot, particularly where detect_dot_context and get_instance_completions are called.

  5. GLM Assistant

    Now let me find where completion is actually assembled/handled (the entry point):

  6. GLM Assistant

    Let me look at the Definition types, particularly Interface:

  7. GLM Assistant

    Now let me understand how interface methods are stored in definitions. Let me search how interfaces are processed in semantics:

  8. GLM Assistant

    Let me look at the existing tests for completion:

  9. GLM Assistant

    Let me look at the test harness to understand how to write a reproduction:

  10. GLM Assistant

    Let me look at the interface stress test to understand the interface syntax:

  11. GLM Assistant

    Now let me write a reproduction test. Let me create a temporary test file:

  12. GLM Assistant

    Now let me check the completion_labels function and the completion method 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) -> string Line 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.

  13. GLM 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.rs test 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.

  14. GLM Assistant

    There's a separate tests package. Let me check it:

  15. GLM Assistant

    I'll add a test entry to Cargo.toml temporarily:

  16. GLM Assistant

    Let me look at the position_to_offset and find_expression_at to understand cursor positioning:

  17. GLM Assistant

    Let me check the existing test for empty-member dot completion (cursor right after the dot):

  18. GLM Assistant

    Let me update my test to position the cursor right after the dot (column 5):

  19. GLM Assistant

    The labels are now empty [], confirming detect_dot_context returns Instance but get_instance_completions returns nothing. This confirms my hypothesis: interface methods have their receiver stripped during registration, so is_instance_method returns false.

    Let me look at how interface method calls are resolved to understand inherited methods:

  20. GLM Assistant

    Let me look at the prelude to find stdlib interfaces, and check how type_name is imported in completion.rs:

  21. GLM Assistant

    Now I understand the issue fully. The stdlib error interface has a method Error() with no self receiver, and user-defined interface methods have their self receiver stripped during registration. In both cases, is_instance_method returns false, so no completions are produced. Let me implement the fix:

  22. GLM Assistant

    Now let me implement the fix. I'll edit get_instance_completions to handle interfaces (including inherited methods from parent interfaces):

  23. GLM Assistant

    Now let me build and run my reproduction test:

  24. GLM Assistant

    The reproduction test passes. Now let me test more edge cases - inherited interface methods, stdlib error interface, and the type-level dot case:

  25. GLM Assistant

    I miscounted the line numbers. Let me fix the cursor positions:

  26. GLM Assistant

    Inherited methods aren't showing. Let me investigate how parent interface types are stored. Let me check convert_to_type:

  27. GLM Assistant

    So convert_to_type resolves the type name via resolve_type_with_arity which returns the qualified name. So the parent type should be a Nominal with the qualified id module.Base. So type_name should return module.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_arity returns and what the final Type is. Let me continue reading.

  28. GLM Assistant

    Let me check whether the parent interface syntax is parsed correctly. Let me look at the parser for interfaces:

  29. GLM Assistant

    The parent interface syntax uses impl Base inside the body, not interface Derived: Base. Let me check existing usage:

  30. GLM Assistant

    The parent interface syntax is impl Base inside the body. Let me fix my test:

  31. GLM Assistant

    The python replace didn't match. Let me view and edit the test directly:

  32. GLM Assistant

    All four tests pass, including inherited interface methods and the stdlib error interface. Now let me run the full existing LSP test suite to make sure nothing is broken:

  33. GLM Assistant

    All 469 LSP tests pass. Let me also run the broader test suites that might be affected:

  34. GLM 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:

  35. GLM Assistant

    The 1513 failures are pre-existing (same count without my change) — likely environment-related (Go toolchain/bindgen). Let me restore my changes:

  36. GLM Assistant

    The suite failures are pre-existing snapshot mismatches (environment-dependent Go/bindgen output producing .snap.new files), unrelated to my change. Let me clean up these test artifacts and verify the UI/lint tests (which involve interfaces) pass:

  37. GLM 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:

  38. GLM Assistant

    Let me fix the double blank line and run rustfmt to ensure clean formatting:

  39. GLM Assistant

    rustfmt fixed the formatting. Let me rebuild and re-run the LSP test suite to confirm everything passes after formatting:

  40. GLM Assistant

    Let me do a final end-to-end verification with the reproduction test (re-create, run, then remove):

  41. GLM Assistant

    All three edge cases pass. Now let me clean up the temporary test artifacts and verify the final state:

  42. GLM Assistant

    The only remaining change is in crates/lsp/src/completion.rs. Let me do a final review of the complete modified function:

  43. GLM Assistant

    The fix looks complete and correct. Let me do a final build check to ensure no warnings:

  44. GLM 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_completions finds methods by scanning Definition::Value entries whose qualified name starts with {type_id}., and filters them with is_instance_method. That helper checks whether the method's first parameter type matches the receiver type. However, interface methods are registered with their self receiver parameter stripped (see populate_interface in crates/semantics/src/checker/registration/methods.rs), and some interface methods (like stdlib error.Error()) have no receiver at all. So is_instance_method always returned false for interface methods, producing zero completions.

    Fix: Added an interface-specific branch in get_instance_completions. When type_id resolves to an Interface definition, it collects the interface's methods directly (subject to visibility, without the is_instance_method check) via a new collect_interface_methods helper that also recursively walks parent interfaces (impl Parent embedding) to include inherited methods, with cycle protection and de-duplication.

    Checklist

    • Reproduced the error: Created a temporary LSP test mirroring the issue (ex. on an Example interface 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 error interface (err. → Error) and inherited interface methods (Derived impl Base → both derived_method and base_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 suite failures are pre-existing environment-dependent Go/bindgen snapshot mismatches (identical 1513 count with and without my change), unrelated to this LSP-only edit.
  45. GLM Assistant

    The user is telling me that I need to submit my changes using the submit command. Let me do that now.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.