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
Now let's build and check compilation.
Assistant
Compiles fine. Now let's write a reproduction test to confirm the fix works, mimicking the discordgo scenario without needing actual network dependency.
Assistant
Test passes with the fix. Let's confirm it fails without the fix (sanity check by reverting temporarily).
Assistant
Confirmed the fix resolves the reported error. Now let's remove the temporary test files and run the full existing test suite to make sure nothing broke.
Assistant
Now run the full test suite to check nothing is broken.
Assistant
Same tests fail in both cases (pre-existing environment issues, likely related to insta snapshot testing needing baseline or parallel test races). This confirms these failures are unrelated to our change. Let's run tests single-threaded to get a more reliable comparison and specifically check tests related to types/convert that we touched.
Assistant
Good — only our intended fix remains. Let's view the final diff for review.
Assistant
All existing "not a type" error tests still pass. Let's also run broader
inferandresolverelated test groups, plus emit tests around types/shadowing, and the ui/errors full suite.Assistant
All ui::errors (608) and spec::infer (1276) tests pass with no failures. This confirms the fix works correctly without regressions in the relevant test suites (emit/build snapshot failures are pre-existing environment issues due to missing
go/gofmtbinary, unrelated to this change).Assistant
Checklist review
-
If an error was reported in the issue description, I have successfully reproduced it. Yes — I built a temporary test (using the existing
infer_with_go_typedefsharness) that mimics the discordgo scenario: a Go-bound module defining bothpub const Unknown: int = 0and a function signature usingUnknownin a type position (fn(Unknown) -> Result<Slice<byte>, error>). Before the fix, this produced the exactresolve.value_in_type_positiondiagnostic described in the issue. I verified this by stashing my fix and re-running the test. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes — after applying the fix, the same reproduction test passes with zero errors. The root cause was in
resolve_type_with_arityincrates/semantics/src/checker/registration/convert.rs: it picked a locally-resolved name (e.g. a Go constantUnknown) whenever its declared type's "arity" (0 for non-generic) happened to match the expected arity in a type position — even though a value/function/enum-variant name can never legitimately be used as a type. This caused it to short-circuit before ever trying the prelude fallback for the builtinUnknowntype. The fix uses the existingclassify_non_type_namehelper to detect this situation and, when detected, prefers a same-named prelude/builtin type before falling back to reporting the original name as an error. -
I have thought about edge cases and made sure my fix handles them as well.
- If the user explicitly writes a package-qualified name (e.g.
discordgo.Unknown), the!type_name.contains('.')guard is preserved, so no incorrect prelude fallback happens — the explicit qualified reference to the value still correctly errors. - If a Go package legitimately defines a real type named
Unknown(not a constant/value),classify_non_type_namereturnsNonefor it, so it is not treated as non-type, and the user's real type correctly takes precedence over prelude (matching existing behavior for other shadowed builtin names likeUnit). - If there is no prelude/builtin alternative available (a genuine user error, e.g. using a function or enum variant name as a type), the code falls through unchanged to the original diagnostic path, preserving existing error-reporting behavior — verified via the existing
infer_not_a_type_*snapshot tests, all of which still pass.
- If the user explicitly writes a package-qualified name (e.g.
-
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Yes — ran the full workspace test suite before and after the fix; the same 1576 tests fail in both cases (confirmed to be pre-existing environment failures caused by the
go/gofmtbinary not being installed in this sandbox, unrelated to this change and unrelated to formatting/semantics). More specifically targeted suites directly relevant to this change —ui::errors(608 tests) andspec::infer(1276 tests) — all pass with zero failures.
Cleaned up all temporary test files/artifacts (
tmp_repro_issue.rs,.snap.newfiles) so only the actual source fix remains in the 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 →
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 →