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!") }Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /lisette, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and understanding how Lisette handles Go bindings and the Unknown type.
- Assistant
Let me explore the bindgen and crates directories more carefully for Unknown type handling.
- Assistant
rg is not found, let me use grep instead.
- Assistant
There's a predeclared_shadowing pass and bindgen — I'll inspect both for how Unknown is handled.
- Assistant
Next I'll inspect bindgen generation of Unknown and how name resolution treats built-in types.
- Assistant
Inspecting the bindgen emitter reserved names and type-name resolution paths.
- Assistant
Looking at convert.rs where the value_in_type_position error is raised.
- Assistant
Let me continue reading convert.rs around the value_in_type_position error.
- Assistant
I need to find
resolve_type_with_arityandclassify_non_type_nameand how type name resolution works, particularly when Unknown constant shadows Unknown type. - Assistant
Let me read those functions.
- Assistant
So the issue is clear: when resolving
Unknownas a type name, it finds the local module'sUnknownconstant (from discordgo) first, before checking the prelude'sUnknowntype. There's already a s... - Assistant
There's already similar handling for Unit and prelude fallback. Checking prelude_shadowing and related tests for the intended pattern.
- Assistant
Checking git history and tests for similar shadowing fixes.
- Assistant
There's a similar issue already fixed: SUS-167 about transitive imports not shadowing types.
- Assistant
Checking prelude types and how bindgen might rename conflicting constants.
- Assistant
There's already a reservedKeywords map — inspecting how bindgen handles name conflicts next.
- Assistant
Looking at the expected behavior again more carefully: I think the cleanest fix is to make Lisette's built-in Unknown type take precedence in type positions when an imported name shadows it. Looking at the resolve_type_with_arity function, I see that it already checks for non-type values and falls back to prelude types in some cases. I should extend that logic to 1) prefer prelude Unknown when we hit a value in type position, and 2) ensure that qualified names like discordgo.Unknown still resolve correctly.
The key insight is that types and values share namespaces in Lisette, so we need explicit precedence rules for built-in types. I'll modify the resolution logic to check prelude first when we detect a value in type position, and update the error handling to be more precise.
Let me also verify that this won't break cases where users intentionally shadow types with local constants, or where enum variants conflict with prelude types. The current classify_non_type_name already handles some of these edge cases nicely.
- Assistant
Confirming: local module symbols are preferred over prelude, so I'll adjust type-position resolution to prefer builtin types when a value shadows them.
- Assistant
Checking CHANGELOG and similar past fixes for preferred approach.
- Assistant
Looking up where Unknown is defined in the stdlib/prelude.
- Assistant
There's alsoOrder
NameUnknownetc - no conflict. Let me check if discordgo or any stdlib has const Unknown. - Assistant
There's already a couple of stdlib packages that have constUnknown - go/constant!
- Assistant
go/constantalready has bothpub const Unknownand uses ofUnknownas a type — checking whether that package typechecks today. - Assistant
Reproducing the issue with a minimal case that shadows
Unknown. - Assistant
It seems cargo build finished but didn't show the lis binary path - maybe it's not emitting because any already built? Let me find and run it.
- Assistant
Reproduced the issue. Implementing the fix so prelude types win in type position when a local value shadows them.
- Assistant
I'll update
resolve_type_with_arityto prefer prelude when local resolution is a non-type. - Assistant
Rebuilding and verifying the reproduction case resolves.
- Assistant
value_in_type_position is fixed. Checking go/constant-style cases and that non-prelude values still error.
- Assistant
Good — Unknown works as a type; Foo still errors. Verifying with an imported go package next.
- Assistant
go/constant works. Reproducing with discordgo as in the issue.
- Assistant
Go isn't available here; go/constant is enough. Running related unit/UI tests for regressions.
- Assistant
All value_in_type tests pass. Checking other type-resolution call sites that need the same fix.
- Assistant
Only one call site needed the change. Running a broader set of resolution-related tests.
- Assistant
All 413 infer tests pass. Running package unit tests and one multi-module Go import case.
- Assistant
Those look like pre-existing emit snapshot failures. Confirming they're unrelated to my change.
- Assistant
Confirmed pre-existing. Cleaning up snapshot noise and verifying the final diff.
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
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →