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
I'll start by exploring the repository structure and understanding how Lisette handles Go bindings and the Unknown type.
- Assistant
Let me look at the bindgen directory and search for how Unknown is handled.
- Assistant
rg is not found, let me use grep instead.
- Assistant
I see reserved-word handling around
Unknownin the emitter. Let me inspect that code and how name conflicts are resolved. - Assistant
Let me look at the emitter.go around those lines more carefully.
- Assistant
Let me investigate how name collisions between constants and built-in types are handled.
- Assistant
There's a reservedKeywords map — let me inspect that and related naming logic.
- Assistant
Checking semantics for Unknown resolution and any existing shadowing/name conflict handling.
- Assistant
That
predeclared_shadowingpass looks directly related — inspecting it now. - Assistant
That's about
anyandcomparable, not about Unknown. Let me look at how registration/convert handles values in type position and how Unknown is resolved. Also let me look at the reserved names in c... - Assistant
So when resolving a type name like "Unknown", it uses
resolve_type_with_arity. The problem is that when there's a constant named Unknown in the same package binding, the name resolves to the constan... - Assistant
Let me look at resolve_type_with_arity and EnvResolve more carefully.
- Assistant
Let me read the resolve_type_name and classify_non_type_name and related code.
- Assistant
So looking at
resolve_type_with_arity: - Assistant
Checking recent changes and how bindgen handles name conflicts with built-in types:
- Assistant
There's a related Option/Result conflict-handling fix — reviewing that pattern and any Unknown-shadowing tests.
- Assistant
Checking how definitions classify types vs values and exploring similar name-collision fixes.
- Assistant
Looking at how definitions distinguish types and whether any tests cover shadowing of prelude types.
- Assistant
There's a test for shadowing prelude types — reading it and related code.
- Assistant
Checking how go_name is used and whether bindgen already handles name conflicts with special types:
- Assistant
Let me look at extract_go_name and how go bindings emit name attributes. Also look at where Unknown is defined in the language.
- Assistant
Let me look at the stdlib prelude.d.lis for Unknown definition, and also check git log for any unfinished work related to this issue.
- Assistant
Looking for existing patterns around value-shadowing of types and reviewing the full resolution path.
- Assistant
Reading the rest of
convert_to_typeto craft the full fix. - Assistant
Looking at the code, I'll implement the fix right after classify_non_type_name detects a value - fall back to prelude. I think the checklist is straightforward: the issue is already reproduced in the description, so I don't need to do extra reproduction work. The fix should resolve the exact error shown, and since it's a name-resolution tweak, edge cases like enum variants or
Optionas a value are already covered by the logic I sketched. - Assistant
Let me look atlookup_qualified_name again - it checks current module first, then unprefixed_imports. So local Unknown const wins over prelude.Unknown.
- Assistant
Checking whether Unknown is restricted to
.d.lisfiles and how it's registered. - Assistant
Implementing a resolver fix so prelude types win over same-named values in type position.
- Assistant
The edit hit the wrong file — reverting and applying it to the correct one.
- Assistant
I need to make
qualified_nameandtymutable. Let me apply the edit correctly. - Assistant
Verifying the fix compiles and reproducing the reported issue.
- Assistant
Writing a temporary reproduction to verify the fix.
- Assistant
Go isn't available here — checking how tests mock go packages so I can reproduce without it.
- Assistant
Reproducing with a temporary test via
infer_with_go_typedefs, then deleting it. - Assistant
Let me look at existing tests with go_typedefs to model my repro世间.
- Assistant
I accidentally put Korean characters. Let me try again.
- Assistant
Let me look at one of those tests ~around line 5146 for a model.
- Assistant
Creating a temporary repro test and building.
- Assistant
I'll stash the fix, confirm the bug with a temp test, then re-apply and verify.
- Assistant
Now add the temporary test at the end.
- Assistant
Fixing the temporary test.
- Assistant
Bug reproduced. Re-applying the fix and verifying.
- Assistant
Fix works. Checking edge cases: enum variants and whether
resolve_type_from_preludeconfuses values with types. - Assistant
The fix was too broad and broke enum-variant errors. Restricting the prelude fallback to actual type definitions.
- Assistant
Need to use a filter pattern for cargo test properly.
- Assistant
Both pass. Expanding edge-case coverage, then removing the temporary test.
- Assistant
All edge cases pass. Removing the temp test and running broader related tests.
- Assistant
Running broader inference/type tests and confirming a clean tree.
- Assistant
Restoring the leftover change in types.rs.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.