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 look at the infer test setup to understand how to test this:
- Assistant
Let me reproduce the issue first. I'll check how the ui error tests work:
- Assistant
Now I'll add a reproduction test and run it to confirm the bug:
- Assistant
Bug reproduced. Now implement the fix in
resolve_type_with_arity: - Assistant
Many failures — let me inspect what broke:
- Assistant
The diff is just a blank line after
package main— suspicious. Let me check whether this fails on a clean tree: - Assistant
All related tests pass. Now run fmt and clippy:
- 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 generatedpub const Unknown: Localeshadowed the prelude's built-intype Unknown, so every use ofUnknownin a type position (e.g.pub var Marshal: fn(Unknown) -> ...in the same.d.lisfile) resolved to the constant, andclassify_non_type_namethen emittedresolve.value_in_type_position.Fix
crates/semantics/src/checker/registration/convert.rs:305— extendedresolve_type_with_aritywith 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_namereturnsSome), - the prelude entry exists, has matching arity, and is itself a type.
If any condition fails, behavior is unchanged — the existing
value_in_type_positiondiagnostics (enum variants, functions, plain values) still fire, confirmed by the passinginfer_not_a_type_*snapshot tests.Test
Added
const_named_unknown_does_not_shadow_builtin_typeintests/spec/infer/types.rs:5043, modeling the discordgo scenario: a.d.lismodule declaring bothpub const Unknown: Localeandpub var Marshal: fn(Unknown) -> Result<Slice<byte>, error>. It reproduces the reported error before the fix and passes after;discordgo.Unknownalso 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 fmtandcargo clippy -p lisette-semantics --all-targets: clean.
- the name is unqualified (no
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 →