Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· 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.
    }
    

    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. Assistant

    I'll start by exploring the repository structure to understand the codebase and locate the LSP implementation. Let's first get a high-level view.

  3. Assistant

    Let's look for LSP-related crates:

  4. Assistant

    Let's explore the LSP crate to understand the codebase structure.

  5. Assistant

    Let me examine the completion module since that's where the issue likely is:

  6. Assistant

    Let me look at the main lib.rs of the LSP crate and understand the overall completion flow:

  7. Assistant

    Let me look at the syntax module to understand the types and definitions:

  8. Assistant

    Let me check the program module to understand how definitions are stored:

  9. Assistant

    Let me look at the program module and definitions to understand how interfaces are structured:

  10. Assistant

    Now I understand the structure. Interfaces have methods: HashMap<EcoString, Type> stored in Interface struct. Let me look at how detect_dot_context works:

    pub(crate) fn detect_dot_context(
        file: &syntax::program::File,
        offset: u32,
        snapshot: &AnalysisSnapshot,
    ) -> Option<DotContext> {
        let Expression::DotAccess {
            expression, member, ..
        } = find_expression_at(&file.items, offset.saturating_sub(1))?
        else {
            return None;
        };
        if !member.is_empty() {
            // If member is not empty, check if it's a type-level access
            // ...
            return None;
        }
    
        // If expression is an identifier, try to find a type definition
        if let Expression::Identifier { value, .. } = expression.as_ref() {
            for prefix in [file.module_id.as_str(), "prelude"] {
                let qualified = format!("{prefix}.{value}");
                if let Some(definition) = snapshot.definitions().get(qualified.as_str())
                    && definition.is_type_definition()
                {
                    return Some(DotContext::TypeLevel(qualified));
                }
            }
        }
    
        // Try to resolve the type of the expression
        let ty = expression.get_type();
        if let Some(type_id) = type_name(&ty) {
            return Some(DotContext::Instance(type_id));
        }
    
        // Handle self in impl blocks
        if let Expression::Identifier { value, .. } = expression.as_ref()
            && value == "self"
            && let Some(impl_type) = find_enclosing_impl_type(&file.items, offset)
        {
            let qualified = format!("{}.{}", file.module_id, impl_type);
            return Some(DotContext::Instance(qualified));
        }
    
        None
    }
    

    The function handles dot-context detection for auto-completion. When a member is empty (user just typed .), it first checks if the expression is a type identifier for static methods, then tries to get the instance type, and finally handles self in impl blocks.

    When get_instance_completions is called with an interface type, it iterates through the definitions map looking for methods whose qualified name starts with {type_id}. and checks if they're instance methods of that type. The key insight is that methods are stored in the definitions map with their fully qualified names, and the function filters for methods that are instance methods of the given interface type.

  11. Assistant

    Let me check the type_name function:

  12. Assistant

    Let me look at the analysis.rs file to understand the type_name function.

  13. Assistant

    Now let me check how interfaces are represented in the type system:

  14. Assistant

    Let me look at the full completion handler in lib.rs to understand the flow:

  15. Assistant

    Let me read the completion handler.

  16. Assistant

    Now let me understand how interface types are represented. Let me look at the semantics module:

  17. Assistant

    Let me look at the dot_access module to understand how interface method calls are resolved:

  18. Assistant

    Let me see the full as_instance_method and get_all_methods functions:

  19. Assistant

    Let me search for get_all_methods in the semantics crate to understand how interface methods are resolved.

  20. Assistant

    Let me find the get_all_methods function definition:

  21. Assistant

    Let me look at the get_all_methods in the checker module:

  22. Assistant

    Now let me look at the store.get_all_methods function:

  23. Assistant

    Now I understand the problem! Let me look at how interfaces are stored vs how get_instance_completions searches for methods.

    The issue is clear:

    1. get_instance_completions looks for methods by scanning definitions for entries like type_id.method_name — but interface methods are stored inside the Interface definition body, not as separate definitions
    2. The is_type_definition() method doesn't include interfaces, which might cause issues in other code paths

    Let me check the peel_alias and get_interface functions:

  24. Assistant

    Now I understand the problem. Let me look at the get_instance_completions function more carefully and understand how it finds methods:

    pub(crate) fn get_instance_completions(
        type_id: &str,
        snapshot: &AnalysisSnapshot,
        same_module: bool,
    ) -> Vec<CompletionItem> {
        let mut items = Vec::new();
    
        if let Some(syntax::program::Definition {
            body: syntax::program::DefinitionBody::Struct { fields, .. },
            ..
        }) = snapshot.definitions().get(type_id)
        {
            // ... add fields
        }
    
        let method_prefix = format!("{type_id}.");
        for (qname, definition) in snapshot.definitions().iter() {
            if let Some(method_name) = qname.strip_prefix(method_prefix.as_str())
                && !method_name.contains('.')
                && matches!(
                    definition.body,
                    syntax::program::DefinitionBody::Value { .. }
                )
                && is_instance_method(definition.ty(), type_id)
                && (same_module || definition.visibility().is_public())
            {
                items.push(CompletionItem {
                    label: method_name.to_string(),
                    kind: Some(CompletionItemKind::METHOD),
                    detail: Some(definition.ty().to_string()),
                    ..Default::default()
                });
            }
        }
    
        items
    }
    

    This function finds methods by looking at definitions with prefix {type_id}. and checks if they're instance methods. For interfaces, the methods would be defined like Interface.method_name just like for other types.

    But wait - how are interface methods stored? Let me look at how methods are collected. From the store.get_all_methods method I see:

    if let Some(interface) = self.get_interface(&qualified_name) {
        let mut all_interface_methods = MethodSignatures::default();
        // ...
        for (name, method_ty) in &interface.methods {
            // ...
        }
        return all_interface_methods;
    }
    

    So interface methods are stored in the Interface.methods hashmap, not as separate definitions. So when we look at the definitions map for entries like main.Example.example, there won't be any because interface methods are stored differently.

    But wait, impl blocks can define methods on interfaces too, right? Let me check.

    Actually, looking at the issue more carefully: the problem is likely that when a variable has an interface type, the type is represented differently from a struct/enum type, and type_name or get_instance_completions can't resolve it.

    Let me look at what type ex: Example would have. In Lisette, when you have:

    interface Example {
      fn example(self, name: string) -> string
    }
    

    And then ex: Example, the type of ex would be the interface type. But in the type system, this might be a Type::Nominal { id: "main.Example", ... }.

    Wait, but I recall that is_type_definition returns false for interfaces. Let me check:

    pub fn is_type_definition(&self) -> bool {
        matches!(
            self.body,
            DefinitionBody::Struct { .. }
                | DefinitionBody::Enum { .. }
                | DefinitionBody::ValueEnum { .. }
                | DefinitionBody::TypeAlias { .. }
        )
    }
    

    It does NOT include DefinitionBody::Interface { .. }. This means that in detect_dot_context, when we check definition.is_type_definition(), interfaces won't match.

    But more importantly, get_instance_completions should still work because it just looks at definitions with the right prefix and checks is_instance_method. The issue is that is_type_definition not including interfaces may prevent the flow from reaching get_instance_completions.

    Let me trace through the completion flow for ex. where ex: Example:

    1. get_module_prefix returns "ex" (because before the dot)
    2. Check if it's an import alias → no
    3. detect_dot_context is called
    4. It finds a DotAccess expression with expression = Identifier("ex") and member = ""
    5. member.is_empty() → true
    6. Check if expression is an identifier and if it's a type definition:
      • Checks "main.ex" and "prelude.ex" → neither matches - Falls through
    7. Gets the type of the expression: ty = expression.get_type() → this is Type::Nominal { id: "main.Example", ... } (or the interface type)
    8. type_name(&ty) → returns Some("main.Example")
    9. Returns Some(DotContext::Instance("main.Example"))
    10. In completion handler, calls get_instance_completions("main.Example", ...)
    11. In get_instance_completions, looks for definitions with prefix "main.Example." and checks is_instance_method

    So the question is: are interface methods stored as separate definitions like main.Example.example? Let me look at how the Store is built.

    Actually, wait. Let me re-read the issue description more carefully. It says "LSP isn't providing completions for interfaces from either stdlib or user-defined."

    So the problem is about completing methods on interface types. When you have ex: Example where Example is an interface, typing ex. should show the interface methods.

    Let me check what happens during semantic analysis when interface methods are resolved. Looking at get_all_methods in the checker:

    pub(crate) fn get_all_methods(&self, store: &Store, ty: &Type) -> MethodSignatures {
        if let Type::Parameter(name) = ty {
            // ... handle type parameters with bounds
        }
    
        let resolved = ty.strip_refs().resolve_in(&self.env);
        // ...
        
        // Interfaces need type-arg-dependent generic substitution, skip cache.
        let peeled = store.peel_alias(&resolved);
        if let Type::Nominal { id: peeled_id, .. } = &peeled
            && store.get_interface(peeled_id).is_some()
        {
            let empty = HashMap::default();
            return store.get_all_methods(&peeled, &empty);
        }
        // ...
    }
    

    So in the semantic checker, when a method call on an interface type is resolved, it goes through get_all_methods which checks if the peeled type is an interface and uses store.get_all_methods.

    In the store's get_all_methods:

    if let Some(interface) = self.get_interface(&qualified_name) {
        let mut all_interface_methods = MethodSignatures::default();
        // ... substitute generics
        for (name, method_ty) in &interface.methods {
            let substituted = substitute(method_ty, &map);
            all_interface_methods.insert(name.clone(), substituted.with_receiver_placeholder());
        }
        // ... handle parent interfaces
        return all_interface_methods;
    }
    

    So interface methods are stored in Interface.methods (inside the DefinitionBody::Interface { definition } body). They are NOT stored as separate definitions in the definitions map.

    This means that get_instance_completions in the LSP, which only looks at the definitions map for entries like type_id.method_name, will NOT find interface methods because they don't exist as separate definitions.

    The fix should be: in get_instance_completions, also check if the type_id corresponds to an interface, and if so, extract methods from the interface definition body.

    Similarly, get_type_completions should handle interfaces for type-level completions.

    Also, is_type_definition should include Interface so that the flow works correctly for type-level completions on interfaces.

    Let me also check if there might be a simpler issue - maybe type_name returns None for interface types. Let me check what type ex: Example would have in the AST.

    Let me now look at how the snapshot is structured and how we can access interface methods:

  25. Assistant

    Now I understand the core issue. Let me trace through what happens when we type ex. where ex: Example:

    1. detect_dot_context is called, finds the dot access
    2. It checks if ex is a type definition - it's not (it's a variable)
    3. It gets the type of the expression via expression.get_type() and calls type_name() on it
    4. If successful, it returns DotContext::Instance(type_id)
    5. Then get_instance_completions is called, which looks for methods with prefix {type_id}. in the definitions map

    The problem: Interface methods are stored in the Interface body (as methods: HashMap<EcoString, Type>), NOT as separate definitions in the definitions map. So get_instance_completions won't find them.

    Let me verify this by looking at how methods for concrete types (structs, enums) are stored vs interfaces:

  26. Assistant

    Now I see the full picture. The get_instance_completions in the LSP only looks for methods as separate definitions (like Type.method), but interface methods are stored inside the Interface body (inside DefinitionBody::Interface { definition } where definition.methods is a HashMap).

    Also, is_type_definition doesn't include Interface, which may cause issues when completing interface type-level access.

    Let me check if there are any existing tests for completion:

  27. Assistant

    Let me check the LSP tests to understand the testing structure:

  28. Assistant

    Let me look at the lsp_harness and search for any existing interface completion tests:

  29. Assistant

    Now I need to understand how interface methods are stored. Let me look at how methods are stored in the definitions map:

  30. Assistant

    Now I have a clear understanding of the issue. Let me also check the is_type_definition usage more broadly:

  31. Assistant

    Let me check the usage of is_type_definition in dot_access.rs:

  32. Assistant

    Now I have a clear picture. The issue is that get_instance_completions only searches for methods in the definitions map (as Type.method entries), but interface methods are stored inside the Interface body (Interface.methods HashMap). Let me also look at the traversal module:

  33. Assistant

    Now I have a clear understanding of the issue. Let me write a reproduction test first:

  34. Assistant

    Let me wait for the build to complete and run the existing tests:

  35. Assistant

    Good, all existing tests pass. Let me look at an existing completion test to understand the pattern:

  36. Assistant

    Now let me create a script to reproduce the issue first:

  37. Assistant

    Let me write a reproduction test by running a script:

  38. Assistant

    Let me check how interface methods are stored:

  39. Assistant

    Now I understand the problem. Let me trace through the code:

    1. When you type ex. where ex: Example (an interface), detect_dot_context correctly identifies it as DotContext::Instance("main.Example")
    2. get_instance_completions is called with type_id = "main.Example"
    3. It looks for definitions with prefix main.Example. - but interface methods are stored INSIDE the Interface definition body (in Interface.methods HashMap), NOT as separate definitions in the definitions map
    4. So no methods are found!

    Also, is_type_definition() doesn't include Interface, which prevents type-level completions on interfaces.

    Let me now implement the fix:

  40. Assistant

    Now let me look at how get_instance_completions should work for interfaces. Let me also check how the get_all_methods in the store handles interfaces with parent methods:

  41. Assistant

    Now I have a clear understanding. The fix needs to be in get_instance_completions in completion.rs. When the type_id is an interface, we need to extract methods from the Interface.methods HashMap instead of looking for separate definitions. Let me implement the fix:

  42. Assistant

    Now I need to understand the exact problem. Looking at the get_instance_completions function:

    1. It looks for struct fields - interfaces don't have fields
    2. It searches definitions for methods with prefix {type_id}. - interface methods are stored in Interface.methods HashMap, NOT as separate definitions

    So when you type ex. where ex is an interface type, no completions are returned.

    The fix: In get_instance_completions, I need to also check if the type_id corresponds to an interface, and if so, extract methods from the Interface.methods HashMap (including parent interface methods).

    Let me also check the is_type_definition function and consider whether it should include interfaces:

  43. Assistant

    Now I have a clear understanding. Let me implement the fix. The core issue is that get_instance_completions doesn't handle interface methods. Interface methods are stored in Interface.methods HashMap, not as separate definitions. Let me modify the function:

  44. Assistant

    Now I see the full picture. The get_instance_completions function works for structs/enums by:

    1. Finding struct fields from the struct definition
    2. Finding methods by scanning all definitions for entries with prefix {type_id}. that are Value definitions with is_instance_method

    But for interfaces, the methods are stored in Interface.methods HashMap (inside the DefinitionBody::Interface { definition: Interface { methods, ... } }), not as separate definitions with names like InterfaceName.method.

    The fix needs to:

    1. In get_instance_completions, check if the type_id is an interface and extract methods from its methods HashMap
    2. Also handle parent interfaces
    3. Also update is_type_definition to include interfaces

    Let me now also check if is_type_definition not including interfaces causes issues in detect_dot_context:

  45. Assistant

    Now let me implement the fix. I'll modify get_instance_completions to handle interface methods:

  46. Assistant

    Let me try a different approach with the edit command:

  47. Assistant

    Let me use sed to make the edit:

  48. Assistant

    Let me write the new version of the file:

  49. Assistant

    Now let me verify the changes compile and run existing tests:

  50. Assistant

    All 48 completion tests pass. Now let me also consider whether is_type_definition() should include Interface. Let me check where it's used:

  51. Assistant

    Let me look at the is_type_level_receiver function in dot_access.rs more closely:

  52. Assistant

    Now let me also check if the is_type_definition issue affects the instance completion path. Looking at detect_dot_context, when we have ex. where ex: Example:

    1. The expression before . is ex (an Identifier with value "ex")
    2. The code checks if main.ex or prelude.ex is a type definition - NO, ex is a variable name
    3. Then it gets the type of the expression via expression.get_type() and returns DotContext::Instance

    So is_type_definition() doesn't affect the instance completion path. My fix in get_instance_completions is sufficient.

    Let me also consider if is_type_definition should include interfaces for other code paths. But this is separate from the reported issue. Let me focus on verifying my fix works.

    Let me run all the LSP tests:

  53. Assistant

    All 469 tests pass. Now let me write a reproduction test to confirm the issue and verify the fix:

  54. Assistant

    Now let me write a temporary test to verify the fix works:

  55. Assistant

    Let me write a quick script to test:

  56. Assistant

    I need to verify my fix works. Let me create a temporary test file and run it:

  57. Assistant

    Now let me run the test:

  58. Assistant

    The test passes. Now let me revert the test addition (since we shouldn't modify existing tests):

  59. Assistant

    Now let me run the full test suite to make sure everything passes:

  60. Assistant

    All 469 tests pass. Now let me also consider whether is_type_definition needs updating for the interface type-level completion case. Let me check if there's a test for Example. where Example is an interface:

  61. Assistant

    The existing tests don't test completions on interface variables. Let me now also consider whether is_type_definition should include Interface for completeness - this would affect type-level completions (like Example.) and also the is_type_level_receiver check in the semantic checker:

  62. Assistant

    Now let me also add Interface to is_type_definition(). This is needed for type-level completions (like Example.) and the is_type_level_receiver check:

  63. Assistant

    Let me verify the change:

  64. Assistant

    Good. Now let me run the full test suite to make sure the is_type_definition change doesn't break anything:

  65. Assistant

    All 469 tests pass. Let me also run the broader test suite to make sure nothing is broken:

  66. Assistant

    Let me check if these failures are pre-existing or caused by my change:

  67. Assistant

    Let me check if these failures are pre-existing by reverting and testing:

  68. Assistant

    Good - the same 3053 passed and 1513 failed exist without my changes. These are pre-existing test failures (likely due to missing Go toolchain). Let me restore my changes:

  69. Assistant

    Good - the 1513 failures are pre-existing and not caused by my changes. Let me verify my final changes:

  70. Assistant

    Let me verify the changes compile and all tests pass:

  71. Assistant

    Let me also run the syntax crate tests:

  72. Assistant

    Let me check the actual package name.

  73. Assistant

    Let me check the package names:

  74. Assistant

    Let me also run the semantics tests:

  75. Assistant

    Let me run the spec tests to make sure nothing is broken:

  76. Assistant

    Let me run the spec tests for the emit and semantics suites (not build, which needs Go):

  77. Assistant

    The emit tests are also failing. Let me check if they fail on the original code too:

  78. Assistant

    The emit and build test failures are pre-existing (they fail both with and without my changes - likely due to missing Go toolchain). Let me now review my final changes:

  79. Assistant

    Let me clean up the snapshot .new files that were created from the pre-existing failures:

  80. Assistant

    Now let me run the LSP tests one final time to confirm everything passes:

  81. Assistant

    Let me also verify there are no other files changed:

  82. Assistant

    The .new snapshot files are from the pre-existing failures. Let me clean them up and do a final review:

  83. Assistant

    Now let me do a final review of the changes:

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