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 implement the fix in resolve_type_with_arity:

  3. Assistant

    Now let me verify with a quick reproduction. First check how the infer test harness works:

  4. Assistant

    User constants must be SCREAMING_SNAKE_CASE, so a plain user const can't be named Unknown. The realistic user-space collision is an enum variant. Let me adjust the test:

  5. Assistant

    Both pass. Let me verify the tests actually fail without the fix (regression validity):

  6. Assistant

    That diff (a missing blank line after package main) looks unrelated. Let me check the baseline on a clean tree:

  7. Assistant

    The test also fails on the clean tree — these are pre-existing environment failures. Let me diff the full failure sets before/after my change to be rigorous:

  8. Assistant

    Identical failure sets (1576 pre-existing environment failures, unrelated gofmt whitespace diffs) — my change introduces zero regressions. Clean up the insta .snap.new artifacts and run fmt/clippy:

  9. Assistant

    All clean. Final review of the change:

  10. Assistant

    One explicit check that the existing value_in_type_position diagnostics still fire correctly:

  11. Assistant

    Done. The fix resolves the discordgo Unknown conflict.

    Summary

    Root cause: In resolve_type_with_arity (crates/semantics/src/checker/registration/convert.rs:292), a type-position name that resolved to a module-level definition was accepted as long as its generic arity matched — even when that definition was a value (like discordgo's Unknown constant). The subsequent classify_non_type_name check then flagged it as resolve.value_in_type_position, so the generated discordgo bindings failed to resolve their own signatures (fn(Unknown) -> ...).

    Fix (convert.rs:303-320): A name resolving to a module-level value can never serve as a type, so it now defers to a prelude type of the same name — exactly mirroring the pre-existing arity-mismatch fallback in the same function. The fallback only fires for unqualified names (Unknown, not dg.Unknown) and only when the prelude entry is itself a real type with matching arity, so:

    • Unknown in the discordgo binding's type positions resolves to the builtin prelude.Unknown, while dg.Unknown in value positions still resolves to the constant
    • Error cases with tailored help keep their diagnostics: prelude variants (fn f() -> None), local functions used as types, and qualified variant names (Kind.String) are unchanged — all 5 existing value_in_type_position snapshot tests pass verbatim

    Tests (tests/spec/infer/types.rs:5818-5864):

    • go_const_named_unknown_does_not_shadow_builtin_type — reproduces the issue with a Go typedef exporting pub const Unknown: Locale alongside VarArgs<Unknown> / fn(Unknown) signatures; fails without the fix, passes with it
    • local_variant_named_unknown_does_not_shadow_builtin_type — locks in that a user enum variant named Unknown doesn't break the builtin type either

    Verification: Ran the full suite before and after the change — the failure sets are byte-identical (1576 pre-existing failures in this environment, all unrelated gofmt blank-line diffs in emit snapshots). cargo fmt --check and cargo clippy are clean.

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