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!") } - Assistant
I'll investigate how Lisette generates Go bindings and resolves the built-in
Unknowntype against imported names like discordgo's constant. - Assistant
Implementing the fix: in type positions, value definitions that shadow prelude builtins (like discordgo's
Unknownconstant) should fall back to the prelude type. - Assistant
The new test passed. Running related type-resolution tests to confirm nothing else regressed.
- Assistant
The broader change broke some error tests — checking what those cases expect.
- Assistant
The first fix was too broad — it turned value-in-type-position errors into type-not-found. I'll limit the prelude fallback to names that actually exist in the prelude.
- Assistant
Fixed. When resolving type names, Lisette now prefers prelude builtins over imported values that share the same name.
Root cause
In generated Go bindings (e.g.
discordgo), signatures likeVarArgs<Unknown>use Lisette's built-inUnknowntype. Butdiscordgoalso exports a constant namedUnknown. Type resolution found the constant first and treated it as a value in a type position, producingresolve.value_in_type_position.Fix
In
resolve_type_with_arity, when an unqualified name resolves to a value (constant, function, etc.) and a matching prelude type exists, the prelude type wins:if let Some((qname, ty)) = self.resolve_type_name(store, type_name) { // When a value shadows a prelude type (e.g. discordgo's `Unknown` // constant vs the prelude `Unknown` type in generated bindings), // prefer the prelude type in type position. if !type_name.contains('.') && let Some(definition) = store.get_definition(&qname) && matches!(definition.body, DefinitionBody::Value { .. }) && let Some((pname, pty)) = self.resolve_type_from_prelude(store, type_name) { return Some((pname, pty)); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.