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 first inspect the repository structure and search for the built-in
Unknowndefinition, Go binding generation, and name resolution logic. Then I’ll identify the narrowest fix, reproduce it with existing tooling or a temporary fixture, and run the relevant tests. - Assistant
ripgrepis unavailable, so I’ll use recursivegrepand inspect the workspace manifests and likely resolver/bindgen source directories. - Assistant
The repository already contains the same collision in the generated
go/constantstandard-library binding (pub const Unknownandfn Make(x: Unknown)), which provides a small local reproduction without downloading discordgo. I’ll inspect semantic registration, scope lookup, built-in registration, and existing UI-test conventions to determine whether type-context lookup can correctly prefer a type while preserving value-context shadowing. - Assistant
The key conversion path calls
resolve_type_with_arity; I’ll now isolate that implementation and the scope data model. I’ll also inspect how top-level values and built-ins are inserted, because the correct behavior likely requires retaining both declarations rather than merely changing lookup order after one has overwritten the other. - Assistant
Scopes currently expose a single
valuesmap, while module definitions also appear keyed by one qualified symbol. I need to see whether “types” are represented in that same map via specialTypevariants and exactly whereUnknownis overwritten. I’ll inspect the focused sections around symbol resolution and module population, plusType’s type/value classification helpers. - Assistant
The broad output confirms definitions are currently one-per-qualified-name, and value registration uses unconditional
insert, so a Go constant can replace the pre-collected type entry only when names coincide within one module. Here the collision is instead with an unprefixed prelude type, so lookup order is central. I’ll capture the exactresolve_type_nameand module scope-loading behavior, and inspect the prelude’sUnknowndeclaration. - Assistant
resolve_type_with_arityalready has a prelude fallback, but only when generic arity differs. Since both the constant’s value type and preludeUnknownhave arity zero, it returns the constant and later reports the diagnostic. A robust, minimally disruptive fix is likely to extend this existing fallback when the first resolution is not itself a type definition, rather than globally changing unified-namespace semantics (which existing diagnostics intentionally enforce). I’ll verify how non-types are detected and reproduce thego/constantfailure through the CLI before editing. - Assistant
I’ll use the existing test harness API pattern to find the quickest reproducible command. If invoking the full CLI needs project setup, I can create a temporary integration-style Rust program or temporary Lisette project outside tracked files. First I’ll inspect the infer helper and CLI package/binary names, then run a baseline test build.
- Assistant
The baseline command used the wrong package name; I’ll check
tests/Cargo.toml. To satisfy reproduction without modifying tests, I’ll create a temporary copy of the repository’s test crate under/tmponly if needed, but the actual stdlib import can likely reproduce directly via a temporary CLI project. I’ll inspect CLI project discovery and help output. - Assistant
A temporary CLI project importing
go:constantshould force registration of the already-generated conflicting typedef and reproduce the same resolver error before any user code is checked. I’ll run that now and preserve its output for before/after comparison. - Assistant
The CLI’s embedded stdlib set does not include
go:constantas an importable package in this build, so that attempt only reached module loading. I’ll instead use the test harness’s custom Go typedef support from a temporary standalone crate under/tmp, referencing workspace crates by path. This directly exercisesparse_and_register_go_modulewith a tiny DiscordGo-equivalent typedef containing bothpub const Unknownand signatures usingUnknown, without changing repository tests. - Assistant
I can reuse the harness source from
/tmpvia Rust’s#[path]attribute; this does not alter repository tests. The temporary executable will callinfer_with_go_typedefs, print resolver codes, and exit nonzero when diagnostics occur. This gives a precise baseline reproduction and can be rerun unchanged after the fix. - Assistant
The temporary directory lacks the repository’s toolchain pin, so
rustupcould not select Cargo. I’ll rerun withRUSTUP_TOOLCHAIN=1.94, matchingrust-toolchain.toml. - Assistant
The harness compiled, but my diagnostic field access was private. I’ll print each diagnostic via its public
Debugimplementation instead; the error count and debug payload are sufficient to confirm the exact resolver code. - Assistant
The reproduction now exactly yields three
resolve.value_in_type_positiondiagnostics at the typedef’sUnknownannotations.I’ll adjust
resolve_type_with_arityto prefer an arity-compatible prelude type only when the unqualified first match classifies as a value. This preserves current behavior for qualified names (pkg.Unknownexplicitly means the package member), preserves local/user diagnostics when no same-named prelude type exists, and reuses the existing prelude fallback policy. I’ll inspect the complete classifier signature, then make the small change. - Assistant
I’ll restructure the existing fallback so an unqualified prelude candidate is considered when either generic arity is wrong or the primary symbol is a non-type value. The prelude candidate must still match the requested arity, preventing accidental selection of an incompatible generic built-in.
- Assistant
The change is in place and formatting/diff checks pass. I’ll rerun the exact temporary reproduction; success should mean zero diagnostics while the constant remains available as a package value.
- Assistant
The exact repro now exits successfully with
errors=0. I’ll strengthen the temporary verification by referencingdiscordgo.Unknownin value position, ensuring the fix did not hide or replace the package constant there. Then I’ll run the semantics/UI test suite, whose existing “value in type position” cases guard against over-broad behavior changes. - Assistant
The focused reproduction including value access passes. The full suite reports a very large correlated failure set (1,576 failures), so I’ll inspect the first failure rather than assume the code caused it; such a broad count typically indicates missing external setup or snapshot environment. I’ll compare representative failures and run the directly relevant resolver tests independently.
- Assistant
The full-suite failures are snapshot tests whose baseline
.snapfiles are absent in this checkout; Insta created.snap.newfiles en masse. Crucially, all five existinginfer_not_a_type_*resolver tests passed, showing ordinary value/type misuse diagnostics remain intact. I’ll remove only the generated.snap.newartifacts, run those resolver tests explicitly, and run the semantics crate tests. - Assistant
Relevant tests all pass, and repository status contains only the intended source change. I’ll perform final static validation with Clippy on the affected crate and a workspace-wide
cargo check, then review the final diff for accidental or overly broad changes.
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 →