ISSUE DESCRIPTION Unknown constant in go dependencies conflicts with Lisette's built-in…
- User
ISSUE DESCRIPTION
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
Let me start by understanding the repository structure and the issue. The issue is about a conflict between a Go package constant named
Unknownand Lisette's built-inUnknowntype. When generating bindings for a Go package (discordgo), the constantUnknownfrom the Go package shadows Lisette's built-inUnknowntype, causing a "value in type position" error.Let me explore the repository structure first.
Assistant
This is a Rust project (Cargo.toml). Let me explore more.
Assistant
Let me explore the key directories. The issue is about binding generation, so
bindgenandcratesare importantAssistant
I need to use a single command.
Assistant
The
bindgendirectory appears to be a Go-based binding generator. Let me explore its structureAssistant
Let me explore the key files. The issue is about how the binding generator handles the
Unknownconstant vs Lisette's built-inUnknownAssistant
Let me look at the emitter and converters to understand how types are emitted
Assistant
Now let me look at the types conversion code
Assistant
Now let me look at converters.go
Assistant
Let me understand how package references and naming collisions are handled. Let me look at the relevant part of converters.go more carefully, specifically the
PkgReffunction and how external packages are trackedAssistant
Let me look at dispatch.go for PkgRef and the resolve logic
Assistant
Let me see the full emitter.go to understand how package references are resolved in emitted output
Assistant
Let me understand how the problem manifests by looking at the semantics crate where name resolution happens
Assistant
Let me search for "Unknown" references in the codebase
Assistant
Let me look at the predeclared shadowing check and how the resolver handles built-in types vs
Assistant
Let me search for the resolve error to understand how name resolution works
Assistant
Let me look at the registration convert code
Assistant
Let me look at how resolve_type_name works in the semantics crate
Assistant
Let me look at the
resolve_type_nameandresolve_type_from_preludeinchecker/mod.rs.Assistant
Let me check if
prelude.Unknowncan be used as a qualified type reference in LisetteAssistant
Let me search for how the prelude is imported and how built-in types are referenced
Assistant
Let me look at how prelude names are made available in the
Assistant
Let me find and look at `lookup_qualified_name
Assistant
Let me look at the lookup_qualified_name function
Assistant
Let me look at how imports are stored and ordered in the checker
Assistant
Let me look at the Import struct and how imports are registered
Assistant
Let me understand how prelude and go imports are registered. Let me look at the import registration code
Assistant
Now I understand the issue. Let me look at how
resolve_type_with_arityworks inconvert.rsmore carefully, and implement the fix.The problem: When
resolve_type_namefinds a name likeUnknownfrom an imported Go package (as a constant/value), it returns it. The function doesn't check whether it's actually a type or a value. Thenclassify_non_type_namecatches it as "value in type position" and errors, never falling back to the prelude.Let me first verify my understanding by looking at how
store.get_typeworks and look at the full flow once more.Assistant
Now I have a clear understanding. The fix should be in
resolve_type_with_arityincrates/semantics/src/checker/registration/convert.rs. Whenresolve_type_namefinds a name that is actually a value (like a constant) rather than a type, we should try the prelude before accepting it as a type match. This way, Lisette's built-inUnknowntype takes precedence over imported constants with the same name.Let me make the edit:
Assistant
Let me use the correct command to open the file.
Assistant
Now I'll apply the fix. The issue is that
resolve_type_with_arityaccepts a name fromresolve_type_nameeven if it's a value (not a type). I need to add a check: if the resolved name is a value, try the prelude first.Assistant
Let me view the exact file content with line numbers to ensure proper indentation
Assistant
Let me use the replace command to make the fix
Assistant
Good, the edit is applied. Now let me build the project to verify the change compiles
Assistant
The code compiles. Now let me run the tests to ensure nothing is broken
Assistant
There are test failures. Let me check if they're related to my change or pre-existing
Assistant
Let me check if these failures are pre-existing by looking at the output of a failing test
Assistant
Let me check if these failures are pre-existing by stashing my changes and running the
Assistant
Good - the test failures are pre-existing. Let me restore my changes
Assistant
The test failures are pre-existing (snapshot updates needed). Let me now run the semantics-specific tests to verify my change doesn't break type
Assistant
All semantics tests pass. Let me also run tests across all crates (excluding the snapshot tests which are pre-existing
Assistant
My fix looks good. Let me verify the final state of the changes
Assistant
Let me check if there are non-snapshot tests that fail
Assistant
Let me check if there are any tests directly related to the type resolution I modified
Assistant
My fix is complete and correct. Let me verify the build once more and submit
Assistant
Let me also clean up the snapshot artifacts from pre-existing test failures before
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.