Unknown constant in go dependencies conflicts with Lisette's built-in Unknown type The…
- 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
discordgodefines 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.
- Assistant
Now let me implement the fix in
resolve_type_with_arity: - Assistant
Now let me verify with a quick reproduction. First check how the infer test harness works:
- 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: - Assistant
Both pass. Let me verify the tests actually fail without the fix (regression validity):
- Assistant
That diff (a missing blank line after
package main) looks unrelated. Let me check the baseline on a clean tree: - 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:
- Assistant
Identical failure sets (1576 pre-existing environment failures, unrelated gofmt whitespace diffs) — my change introduces zero regressions. Clean up the insta
.snap.newartifacts and run fmt/clippy: - Assistant
All clean. Final review of the change:
- Assistant
One explicit check that the existing
value_in_type_positiondiagnostics still fire correctly: - Assistant
Done. The fix resolves the discordgo
Unknownconflict.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'sUnknownconstant). The subsequentclassify_non_type_namecheck then flagged it asresolve.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, notdg.Unknown) and only when the prelude entry is itself a real type with matching arity, so:Unknownin the discordgo binding's type positions resolves to the builtinprelude.Unknown, whiledg.Unknownin 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 existingvalue_in_type_positionsnapshot 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 exportingpub const Unknown: LocalealongsideVarArgs<Unknown>/fn(Unknown)signatures; fails without the fix, passes with itlocal_variant_named_unknown_does_not_shadow_builtin_type— locks in that a user enum variant namedUnknowndoesn'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 --checkandcargo clippyare clean.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →