Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Unknown constant in go dependencies conflicts with Lisette's built-in Unknown type The…

  1. User

    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!")
    }
    

    Interface

    No new interfaces are introduced.

  2. Assistant

    Now let me look at the infer test setup to understand how to test this:

  3. Assistant

    Let me reproduce the issue first. I'll check how the ui error tests work:

  4. Assistant

    Now I'll add a reproduction test and run it to confirm the bug:

  5. Assistant

    Bug reproduced. Now implement the fix in resolve_type_with_arity:

  6. Assistant

    Many failures — let me inspect what broke:

  7. Assistant

    The diff is just a blank line after package main — suspicious. Let me check whether this fails on a clean tree:

  8. Assistant

    All related tests pass. Now run fmt and clippy:

  9. Assistant

    The fix is complete. Summary of what was done:

    Root cause

    In resolve_type_with_arity (crates/semantics/src/checker/registration/convert.rs), an unqualified name in a type position resolved to whatever the module scope found first. In the discordgo bindings module, the generated pub const Unknown: Locale shadowed the prelude's built-in type Unknown, so every use of Unknown in a type position (e.g. pub var Marshal: fn(Unknown) -> ... in the same .d.lis file) resolved to the constant, and classify_non_type_name then emitted resolve.value_in_type_position.

    Fix

    crates/semantics/src/checker/registration/convert.rs:305 — extended resolve_type_with_arity with a prelude fallback mirroring the existing arity-mismatch fallback: when the locally-resolved name is a value (not a type) and the prelude has a same-named type with the right arity, the prelude type takes precedence in type positions. The fallback only kicks in when:

    • the name is unqualified (no .),
    • the local resolution classifies as a value (classify_non_type_name returns Some),
    • the prelude entry exists, has matching arity, and is itself a type.

    If any condition fails, behavior is unchanged — the existing value_in_type_position diagnostics (enum variants, functions, plain values) still fire, confirmed by the passing infer_not_a_type_* snapshot tests.

    Test

    Added const_named_unknown_does_not_shadow_builtin_type in tests/spec/infer/types.rs:5043, modeling the discordgo scenario: a .d.lis module declaring both pub const Unknown: Locale and pub var Marshal: fn(Unknown) -> Result<Slice<byte>, error>. It reproduces the reported error before the fix and passes after; discordgo.Unknown also remains usable as a value.

    Verification

    • New test: passed (failed with the exact reported error before the fix).
    • Full suite: the failure set is byte-for-byte identical to the clean-tree baseline (1576 pre-existing failures in this environment — whitespace-only emit-snapshot diffs like a missing blank line after package main, unrelated to this change). Zero new failures.
    • cargo fmt and cargo clippy -p lisette-semantics --all-targets: clean.

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