Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Unknown constant in go dependencies conflicts with Lisette's built-in…

  1. User

    ISSUE DESCRIPTION

    Unknown constant in go dependencies conflicts with Lisette's built-in Unknown type The discordgo package defines a constant named Unknown (used for unrecognized types/events), which conflicts with Lisette's built-in Unknown type. When Lisette generates bindings for discordgo, any function signature that uses Unknown as a type parameter is misinterpreted — the compiler sees the discordgo value Unknown in a type position, causing a resolve.value_in_type_position error.

    Error output:

      🔴 Value in type position
          ╭─[go:github.com_bwmarrin_discordgo.d.lis:4693:46]
     4692 │ /// Logger can be used to replace the standard logging for discordgo
     4693 │ pub var Logger: fn(int, int, string, VarArgs<Unknown>) -> ()
          ·                                              ───┬───
          ·                                                 ╰── expected type, found value
     4694 │
          ╰────
      help: Only a type is allowed here · code: [resolve.value_in_type_position]
    
      🔴 Value in type position
          ╭─[go:github.com_bwmarrin_discordgo.d.lis:4695:21]
     4694 │
     4695 │ pub var Marshal: fn(Unknown) -> Result<Slice<byte>, error>
          ·                     ───┬───
          ·                        ╰── expected type, found value
     4696 │
          ╰────
      help: Only a type is allowed here · code: [resolve.value_in_type_position]
    
      🔴 Value in type position
          ╭─[go:github.com_bwmarrin_discordgo.d.lis:4697:36]
     4696 │
     4697 │ pub var Unmarshal: fn(Slice<byte>, Unknown) -> Result<(), error>
          ·                                    ───┬───
          ·                                       ╰── expected type, found value
     4698 │
          ╰────
      help: Only a type is allowed here · code: [resolve.value_in_type_position]
    

    Root Cause

    discordgo defines a constant named Unknown (e.g. Unknown Locale). Lisette also has a built-in type named Unknown used to represent opaque/untyped Go values in bindings. When the binding generator emits Unknown in a type position, the name resolves to the discordgo constant value instead of the Lisette type, triggering the error.

    Expected Behavior

    Lisette's built-in Unknown type should take precedence in type positions, or the binding generator should qualify/disambiguate imported names that shadow built-in types.

    Reproduction

    Add github.com/bwmarrin/discordgo as a dependency and run lis run. The error appears immediately during binding resolution without any user-written code.

    import "go:fmt"
    import "go:github.com/bwmarrin/discordgo"
    
    const TOKEN = "token"
    
    fn main() {
      let _discord = try {
        discordgo.New("Bot" + TOKEN)?
      }
    
      fmt.Println("Hello world!")
    }
    

    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 relevant files. Let me first check the current directory and look at the repository layout.

  3. Assistant

    Let me explore the repository structure more thoroughly to understand how it's organized and find the binding generation code.

  4. Assistant

    Let me explore the bindgen directory more closely since that's likely where the binding generation happens.

  5. Assistant

    Let me understand the issue. The problem is:

    1. discordgo package defines a constant named Unknown (e.g., for Unknown Locale)
    2. Lisette has a built-in type named Unknown used to represent opaque/untyped Go values in bindings
    3. When the binding generator emits Unknown in a type position, the name resolves to the discordgo constant value instead of the Lisette type, triggering a resolve.value_in_type_position error

    The fix should ensure that Lisette's built-in Unknown type takes precedence in type positions, or the binding generator should qualify/disambiguate imported names that shadow built-in types.

    Let me explore the bindgen code to understand how types are resolved and how Unknown is used.

  6. Assistant

    Let me look at the convert and emit directories to understand how types are processed.

  7. Assistant

    Let me search for "Unknown" in the codebase to understand how it's used.

  8. Assistant

    Let me look at the emit/emitter.go file to see what "Unknown" is used for.

  9. Assistant

    Now let me understand the emit/emitter.go file better - this seems to be where the Lisette code generation happens.

  10. Assistant

    Let me look at the emitter to understand how it handles types and how they are imported/qualified.

  11. Assistant

    Let me look at how types are emitted, particularly how the emitter handles type references and whether it qualifies them with the package name.

  12. Assistant

    Let me look at the types.go file in convert to understand how types are converted.

  13. Assistant

    Let me examine the emitter more closely to understand how types are emitted and how the Unknown type is handled:

  14. Assistant

    Let me look at the full emitter to understand how types are emitted and how the Unknown type is handled.

  15. Assistant

    Let me check the Rust side to understand how the Lisette compiler resolves types.

  16. Assistant

    Let me look at the prelude to understand what Lisette's built-in Unknown type is.

  17. Assistant

    Let me search for "Unknown" in the Rust codebase to understand how it's handled as a built-in type.

  18. Assistant

    Let me search for value_in_type_position to understand how the error is generated.

  19. Assistant

    Let me look at the semantics/src/checker/registration/convert.rs file to understand how the error is triggered.

  20. Assistant

    Let me look at the classify_non_type_name function to understand what it does.

  21. Assistant

    Let me look at more of this function to understand what it returns and when it triggers the error.

  22. Assistant

    Let me understand how the compiler resolves types:

  23. Assistant

    Let me look at resolve_type_name to understand how it resolves names.

  24. Assistant

    Let me find where resolve_type_name is defined.

  25. Assistant

    Let me look at that function.

  26. Assistant

    Let me check how Unknown is defined in the prelude and how it's registered:

  27. Assistant

    Let me look at the builtins registration:

  28. Assistant

    Let me look at resolve_type_with_arity to understand how types with arity are resolved:

  29. Assistant

    Let me look at lookup_qualified_name to understand how names are resolved in scope:

  30. Assistant

    Let me look at lookup_qualified_name in the checker module.

  31. Assistant

    Let me check how other builtin types like error are handled in the binding generator:

  32. Assistant

    Let me look at how the prelude defines the Unknown type. Let me search the stdlib crate.

  33. Assistant

    Let me look at the prelude.d.lis file to see how the Unknown type is defined.

  34. Assistant

    Let me look at how the binding generator handles imports and see if there's a way to qualify types: Lisette>

  35. Assistant

    Let me look at how the resolution works more carefully. The issue is that when Unknown appears in a type position in a generated .d.lis file, the resolver first finds the Unknown constant from the imported Go package (discordgo) before finding the prelude's Unknown type.

    Looking at the resolve_type_with_arity function:

    pub(super) fn resolve_type_with_arity(
        &mut self,
        store: &Store,
        type_name: &str,
        expected_arity: usize,
    ) -> Option<(String, Type)> {
        let arity_of = |ty: &Type| match ty {
            Type::Forall { vars, .. } => vars.len(),
            _ => 0,
        };
    
        if let Some((qname, ty)) = self.resolve_type_name(store, type_name) {
            if arity_of(&ty) == expected_arity {
                return Some((qname, ty));
            }
            if !type_name.contains('.')
                && let Some((pname, pty)) = self.resolve_type_from_prelude(store, type_name)
                && arity_of(&pty) == expected_arity
            {
                return Some((pname, pty));
            }
            return Some((qname, ty));
        }
    
        self.resolve_type_from_prelude(store, type_name)
    }
    

    And resolve_type_name:

    pub(crate) fn resolve_type_name(
        &mut self,
        store: &Store,
        type_name: &str,
    ) -> Option<(String, Type)> {
        if self.scopes.lookup_type_param(type_name).is_some() {
            return None;
        }
    
        let qualified_name = self.lookup_qualified_name(store, type_name)?;
        let ty = store.get_type(&qualified_name)?.clone();
    
        Some((qualified_name.to_string(), ty))
    }
    

    And lookup_qualified_name:

    pub(crate) fn lookup_qualified_name(
        &self,
        store: &Store,
        type_name: &str,
    ) -> Option<EcoString> {
        // Check prefixed imports first
        if let Some((prefix, simple_name)) = type_name.split_once('.')
            && let Some(module_id) = self.imports.prefix_to_module.get(prefix)
            && let Some(imported_module) = store.get_module(module_id)
            && let Some((qualified_name, _)) =
                self.resolve_in_imported_module(imported_module, simple_name)
        {
            return Some(qualified_name.into());
        }
    
        // Check current module
        let module = store.get_module(&self.cursor.module_id)?;
        let qualified_name = Symbol::from_parts(&module.id, type_name);
        if module.definitions.contains_key(qualified_name.as_str()) {
            return Some(qualified_name.as_eco().clone());
        }
    
        // Check unprefixed imports
        for imported_module_id in &self.imports.unprefixed_imports {
            if let Some(imported_module) = store.get_module(imported_module_id) {
                let qualified_name = Symbol::from_parts(imported_module_id, type_name);
                if imported_module
                    .definitions
                    .contains_key(qualified_name.as_str())
                {
                    return Some(qualified_name.as_eco().clone());
                }
            }
        }
    
        None
    }
    

    So the problem is:

    1. resolve_type_name looks up Unknown in the current module and unprefixed imports
    2. It finds Unknown as a constant in the discordgo import (e.g., go:github.com/bwmarrin/discordgo.Unknown)
    3. store.get_type returns the type of that constant (which is some value type, not the Unknown type)
    4. Back in resolve_type_with_arity, since the type was found (just not with the right arity), it returns it
    5. The classify_non_type_name function then detects it's a value, not a type, and reports the error

    Wait, let me re-read the flow more carefully.

    Looking at resolve_type_with_arity:

    if let Some((qname, ty)) = self.resolve_type_name(store, type_name) {
        if arity_of(&ty) == expected_arity {
            return Some((qname, ty));
        }
        if !type_name.contains('.')
            && let Some((pname, pty)) = self.resolve_type_from_prelude(store, type_name)
            && arity_of(&pty) == expected_arity
        {
            return Some((pname, pty));
        }
        return Some((qname, ty));  // <-- This returns the discordgo value
    }
    
    self.resolve_type_from_prelude(store, type_name)
    

    So the issue is:

    1. resolve_type_name finds the discordgo Unknown constant (a value)
    2. Its arity doesn't match (it's 0, expected_arity is whatever)
    3. It tries to fall back to prelude, but the prelude's Unknown also has arity 0
    4. So it falls through to return Some((qname, ty)) — returning the discordgo value5. The caller then sees it's a value, not a typeWait, for the case in the error, Unknown appears without type parameters (e.g., VarArgs<Unknown>). So expected_arity would be 0. The discordgo Unknown constant has arity 0. The prelude Unknown type also has arity 0. So it returns the first one found.

    The fix should be at the resolution level. When a name Unknown is used in a type position, and it resolves to a value (not a type), the resolver should check the prelude for a type with the same name.

    Actually, looking at the flow more carefully:

    In resolve_type_with_arity:

    • resolve_type_name finds the discordgo Unknown constant, returns (qname, type_of_constant)
    • arity_of(&type_of_constant) == expected_arity — if expected_arity is 0, and the constant has arity 0, it returns immediately
    • If expected_arity is not 0, it checks the prelude, and if the prelude version matches, returns that

    The problem is that when Unknown is used without generics (arity 0), the discordgo constant also has arity 0, so it's returned directly without checking the prelude.

    Now, in the calling code in convert.rs:

    if let Some((qname, ty)) =
        self.resolve_type_with_arity(store, type_name, params.len())
    else {
        // type not found
    };
    
    if let Some((kind, help)) =
        self.classify_non_type_name(store, &qualified_name, type_name)
    {
        // error: value in type position
    };
    

    So the fix needs to happen somewhere in this flow. There are a few possible approaches:

    1. In the bindgen: Instead of emitting Unknown as the type name, emit it with a prelude qualification like prelude.Unknown so the resolver knows to look in the prelude, not in the imported package.

    2. In the resolver: When resolving a name in a type position, prefer a type from the prelude over a value from an imported module.

    3. In the resolver: When resolve_type_with_arity finds a value (not a type) from a module, fall back to the prelude before returning.

    Let me think about which approach is best. The issue description says:

    Lisette's built-in Unknown type should take precedence in type positions, or the binding generator should qualify/disambiguate imported names that shadow built-in types.

    Option 1 seems simplest and most targeted: in the bindgen, when emitting Unknown as a type, we should ensure it's distinguishable from a constant named Unknown in the imported package.

    But wait, the issue is that Unknown IS a built-in type in the prelude. The resolver should be finding it. Let me re-examine the resolution order:

    1. Current module definitions
    2. Unprefixed imports
    3. (If not found, then) prelude

    The problem is step 2 finds the discordgo Unknown constant, and it's returned as a hit before the prelude is checked.

    The cleanest fix would be in the resolver: when resolve_type_with_arity gets back a value (not a type definition) from an imported module, and there's a type with the same name in the prelude, prefer the prelude version.

    Actually, let me re-read classify_non_type_name:

    pub(super) fn classify_non_type_name(
        &self,
        store: &Store,
        qualified_name: &str,
        type_name: &str,
    ) -> Option<(&'static str, Option<String>)> {
        let definition = store.get_definition(qualified_name)?;
        if !matches!(definition.body, DefinitionBody::Value { .. }) {
            return None;
        }
        // ... it's a value, not a type
    }
    

    So it checks if the definition is a Value. If it is, it's considered a non-type name.

    Now, the issue is in the resolution order. Let me look at the full flow for convert_to_type more carefully:

  36. Assistant

    Now let me understand the full flow. Let me look at the complete convert_to_type method:

  37. Assistant

    Now I understand the issue clearly. Let me trace through the resolution logic.

    When Unknown appears in a type position (e.g., VarArgs<Unknown>) in a .d.lis file for discordgo:

    1. convert_to_type calls resolve_type_with_arity(store, "Unknown", 0)
    2. Inside resolve_type_with_arity, it calls resolve_type_name(store, "Unknown")
    3. resolve_type_name calls lookup_qualified_name(store, "Unknown")
    4. lookup_qualified_name finds go:github.com_bwmarrin_discordgo.Unknown (the constant) in the current module
    5. store.get_type returns the type of that constant (e.g., Locale)
    6. Back in resolve_type_with_arity, arity 0 matches, so it returns the discordgo constant type
    7. classify_non_type_name detects it's a value definition, not a type → error

    The fix should be: in resolve_type_with_arity, when the resolved name is a value definition (not a type), and the prelude has a type with the same name, prefer the prelude type.

    Let me check what DefinitionBody variants exist:

  38. Assistant

    Let me find the DefinitionBody type.

  39. Assistant

    Let me look at DefinitionBody enum to understand the different kinds of definitions.

  40. Assistant

    Now I understand the full picture. Let me look at existing tests to see if there's a test for this kind of conflict.

  41. Assistant

    Let me look at the bindgen tests to understand the testing approach.

  42. Assistant

    Let me look at the predeclared_shadowing pass to understand how builtins are handled:

  43. Assistant

    Now I understand the full picture. The issue is in the resolve_type_with_arity method. When resolving Unknown in a type position within a .d.lis file that also defines a constant named Unknown, the resolution finds the constant first (from the current module) and returns it. Since it's a value (not a type), classify_non_type_name correctly flags it as an error.

    The fix should be in resolve_type_with_arity. When the resolved name is a value definition (not a type), and the prelude has a type with the same name, prefer the prelude type.

    Let me look at how the Store works to check definitions:

  44. Assistant

    Now I understand the problem. Let me look at the full flow more carefully. The issue is in resolve_type_with_arity - when the resolved name from the scope is a Value definition (not a type), and the prelude has a type with the same name, the prelude type should take precedence. Let me check how store.get_definition works:

  45. Assistant

    Now I understand the problem and the fix. Let me look at what imports are available in the convert.rs file:

  46. Assistant

    Now I understand the full picture. The fix should be in resolve_type_with_arity - when the resolved name is a Value definition (constant/variable), and the prelude has a type with the same name that matches the expected arity, prefer the prelude type.

    Let me implement this:

  47. Assistant

    Let me look at the exact lines I need to modify:

  48. Assistant

    Let me also check how the type is stored for a value/constant definition:

  49. Assistant

    Now I understand the full picture. Let me trace through the issue again:

    1. In the generated .d.lis file for discordgo, there's a constant Unknown (from Go's discordgo.Unknown locale constant)
    2. When processing a type annotation like VarArgs<Unknown>, the compiler tries to resolve Unknown as a type
    3. resolve_type_name is called, which calls lookup_qualified_name
    4. lookup_qualified_name checks the current module first and finds go:github.com_bwmarrin_discordgo.Unknown (the constant)
    5. store.get_type(&qualified_name) returns the type of the constant (e.g., the Locale type)
    6. Back in resolve_type_with_arity, arity_of(&ty) is 0 and expected_arity is 0, so it matches and returns
    7. Back in convert_to_type, classify_non_type_name checks if the resolved name is a Value definition, and it is → error

    The fix should be: in resolve_type_with_arity, when the resolved name from the scope is a Value definition, prefer the prelude type if it exists.

    Let me implement this fix:

  50. Assistant

    Now let me verify the change looks correct:

  51. Assistant

    Good, the change looks correct. Now let me build the project to make sure it compiles:

  52. Assistant

    Great, the build succeeded. Now let me run the existing tests to make sure I didn't break anything:

  53. Assistant

    Let me check if these test failures are pre-existing by reverting my change and running tests again:

  54. Assistant

    The test failures are pre-existing (same number: 3572 passed, 1576 failed). This means my change didn't break anything. Now let me restore my change and verify it's still there:

  55. Assistant

    Good. The test failures are pre-existing - same count (1576) both before and after my change. Let me now run the specific test suite for the semantics crate to make sure my change doesn't introduce any regressions:

  56. Assistant

    All 54 tests in the semantics crate pass. Now let me look at the test fixtures to see if there are any related tests:

  57. Assistant

    Let me look for tests related to the value-in-type-position error:

  58. Assistant

    Let me look for relevant test fixtures that test this scenario.

  59. Assistant

    Let me search for relevant test files more broadly.

  60. Assistant

    Let me find the test files.

  61. Assistant

    Let me look at the test structure and find where the value_in_type_position error test might be:

  62. Assistant

    Let me find the resolve tests:

  63. Assistant

    Let me look at the test structure more broadly.

  64. Assistant

    Let me look for existing test fixtures that might be relevant.

  65. Assistant

    Let me look at the foreign_typed_const fixture since it seems related:

  66. Assistant

    Let me look for the test that relates to the semantics crate to check that the existing test suite still passes:

    Now let me create a test to verify my fix works. First, let me understand the test infrastructure:

  67. Assistant

    Let me look at the test infrastructure more to understand how tests are structured.

  68. Assistant

    Let me look at the existing tests to understand how they test for the value_in_type_position error.

  69. Assistant

    Let me look at the existing test snapshots to see if there are any that test the value_in_type_position error:

  70. Assistant

    Let me look at these test snapshots to understand the existing behavior:

  71. Assistant

    Let me look at the actual test that generates this error:

  72. Assistant

    Let me check how enum variants are stored to understand if my change could affect them:

  73. Assistant

    Let me verify my understanding by checking if the existing test infer_not_a_type_unit_variant_prelude still works with my change. The key question is: are there cases where an enum variant is a Value definition AND there's a prelude type with the same name?

    Let me check what the prelude types are:

  74. Assistant

    Good. Now let me verify that the existing tests still pass with my change. Let me run the full test suite again and compare:

  75. Assistant

    Let me run the UI error tests to verify:

  76. Assistant

    All 608 UI error tests pass. Let me also run the infer tests:

  77. Assistant

    All 401 infer tests pass. Let me also verify the specific tests about value-in-type-position:

  78. Assistant

    Let me look at the full test suite to make sure my change doesn't break anything:

  79. Assistant

    Same 3572 passed, 1576 failed - exactly the same as before my change. The failures are pre-existing. My change didn't break anything.

    Now let me check if the 1576 failed tests are the same ones. Let me look at one of the failed tests to understand why they fail:

  80. Assistant

    Let me check if these are snapshot test failures (missing .snap.new files):

  81. Assistant

    The test failures appear to be snapshot-related tests that need .snap.new files created. These are pre-existing failures unrelated to my change (since the same count of 1576 failures appears both with and without my change). Let me verify this:

  82. Assistant

    Let me check what's going on with the failing tests. Let me look at one specific failing test.

  83. Assistant

    The failures are pre-existing snapshot mismatches, not related to my change. Let me now create a test to verify my fix works for the specific issue described. Let me first look at how UI tests work:

  84. Assistant

    Now let me verify my change is correct by looking at the diff:

  85. Assistant

    The change looks correct and minimal. Let me now verify the fix with a more comprehensive test. Let me check if there are any related existing tests that specifically test the Unknown type usage:

  86. Assistant

    The test failures are all pre-existing snapshot mismatches (.snap.new files being generated). Let me verify this is consistent:

  87. Assistant

    Let me also verify that the .snap.new files were already present before my change (confirming these are pre-existing failures):

  88. Assistant

    Good - the 1573 .snap.new files already exist, confirming these are pre-existing failures. My change doesn't add or remove any .snap.new files.

    Now let me verify the final diff:

  89. Assistant

    Now let me review the final diff. The change is minimal and targeted. Let me verify the semantics crate builds cleanly:

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