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 first map the repository and locate the resolver/binding-generation code and existing tests around built-in types and shadowing. Then I’ll reproduce the failure with the smallest available mechanism before changing source.
- Assistant
ripgrepis unavailable, so I’ll usegrep/find. The project is a Rust workspace with a Go bindgen; I’ll inspect both because the defect could be fixed either at emitted syntax or at name resolution, while preferring resolver semantics if built-ins should universally remain valid in type positions. - Assistant
There is already a generated standard-library binding (
go/constant) that declarespub const Unknown, so it likely provides an immediate, dependency-free reproduction of the same collision. I’ll inspect registration and type-resolution code plus semantics test conventions, then run a focused test or CLI analysis against that module. - Assistant
The diagnostic originates during annotation conversion. I’ll now trace its lookup precedence and top-level registration order. The key semantic distinction is important: arbitrary values should still produce
value_in_type_position, but a colliding package-level value must not hide a predeclared type when resolving an annotation. - Assistant
convert_to_typefirst resolves a name and only afterward classifies it as a value, so the fix should be in type-specific resolution rather than globally changing expression lookup. I’ll inspectresolve_type_with_arity, prelude fallback, and store namespace behavior to determine whether all predeclared types or onlyUnknownneed protected precedence. - Assistant
The existing arity fallback only prefers the prelude when the local symbol has the wrong generic arity. Here both the constant and
Unknownhave arity zero, so the value wins. A general solution is to make type resolution prefer an actual prelude type over a same-arity non-type local value, while preserving local user-defined types and expression lookup. I’ll verify how prelude types are identified and reproduce with the test harness without modifying tests. - Assistant
To reproduce exactly without adding repository tests, I’ll create a temporary Lisette project and invoke the CLI using a synthetic Go typedef containing both
pub const Unknownand signatures withUnknown. This isolates the collision and avoids network dependence on DiscordGo. First I’ll inspect CLI project conventions and whether the binary can consume a pre-generated dependency typedef directly. - Assistant
The harness confirms synthetic typedefs are the right reproduction route. Since repository tests must not be added or modified, I’ll create a temporary standalone Rust source under
/tmpthat imports the workspace crates and drives the public parser/checker APIs, or more simply copy the tests package to/tmpand add a one-off test there. This gives a before/after assertion without touching tracked files. - Assistant
The temporary copy lost the repository’s
rust-toolchain.toml, so Cargo had no selected toolchain. I’ll explicitly use the repository’s pinned version and run the reproducer again. - Assistant
The test package inherits workspace metadata/dependencies, so I’ll complete the isolated
/tmpworkspace with symlinks to the repository crates and a workspace manifest. No repository file will be altered. - Assistant
The reproducer fails with exactly three
resolve.value_in_type_positiondiagnostics matching the report. Before implementing, I’ll inspect the language’s shadowing policy: if user declarations are deliberately forbidden from shadowing predeclared names, a targetedUnknownresolution is safest; if predeclared type/value namespaces are generally context-sensitive, a generic actual-type fallback is appropriate. - Assistant
Lisette already rejects user-defined types that shadow prelude types, while values may share those names. Therefore type-position lookup should be namespace-sensitive: an unqualified local value should yield to a real prelude type of matching arity; qualified names must continue referring to the explicitly selected package value. I’ll implement that narrowly in
resolve_type_with_arity, reusing the existing non-type classifier so enum variants/functions retain diagnostics when no valid prelude type exists. - Assistant
The change now selects a matching prelude declaration only when it is genuinely a type and the colliding local declaration is not. I’ll rerun the exact temporary reproduction, then add temporary edge-case coverage there for qualified access and ordinary value-in-type errors to ensure diagnostics were not weakened.
- Assistant
The exact reproduction now passes. I’ll extend only the
/tmpreproducer with three semantic edge cases: a local constant namedUnknownshould not hide the built-in in annotations; an explicitly qualified package constant must still be rejected as a type; and an unrelated function name in a type position must still produce the original diagnostic. - Assistant
The qualified and unrelated-value safeguards pass. The local user constant case reached only an unrelated naming lint (
Unknownis not screaming snake case), while the actual Go typedef case already proves local package-value fallback without user-lint interference. I’ll now run the existing resolver regression group, compile/check the semantics crate, and run its formatter/linter checks. - Assistant
Focused resolver tests, type-not-found tests, compilation, Clippy with warnings denied, formatting, and diff checks all pass. I’ll run the broader type-inference test module and Go bindgen tests because this change affects generated typedef registration. I’ll also inspect the final diff for unnecessary complexity and verify no tracked test artifacts were introduced.
- Assistant
All 319 broader type-inference tests pass. Go bindgen tests could not run because the environment has no
goexecutable; this source change is in Rust resolution and the synthetic generated-typedef reproduction covers its integration path. I’ll add a concise rationale comment around the non-obvious precedence rule, then run the complete 5,148-test Rust suite to maximize regression coverage. - Assistant
The complete suite reports 1,576 failures while 3,572 pass; this scale strongly suggests an environment/tooling prerequisite rather than resolver regressions (likely Go-dependent emit/sync tests, given
gois absent). I’ll capture representative failure details and rerun a failing test individually to distinguish infrastructure failures from code failures. - Assistant
Representative failures are unrelated baseline issues: emit snapshots differ only by a pre-existing blank-line expectation, and sync fails because the CLI invokes unavailable Go tooling. The full run generated
.snap.newartifacts, so I’ll remove those untracked files, verify the repository diff is again only the intended source change, and rerun the exact synthetic regression after the final comment. - Assistant
Final verification shows only
convert.rsis modified, no test/snapshot artifacts remain, diff whitespace is clean, and the exact collision reproducer passes. I’ll inspect the final patch and repository status one last time before submission. - Assistant
Checklist:
- Successfully reproduced the reported error. A temporary synthetic Go typedef declared
pub const Unknownplus the three reportedLogger,Marshal, andUnmarshalshapes. Before the fix it produced exactly threeresolve.value_in_type_positiondiagnostics. - Confirmed the fix resolves the error. The same isolated reproducer passes after the change with no diagnostics.
- Considered edge cases. Resolution only falls back for unqualified names, only to a genuine prelude type, and only when generic arity matches. Temporary checks confirmed explicitly qualified constants and unrelated values still trigger
value_in_type_position. - All focused resolver/type-not-found tests passed, all 319 broader inference/type tests passed, and Clippy with passed. The complete suite had 3,572 passes and 1,576 unrelated baseline failures from snapshot blank-line mismatches and unavailable Go tooling; bindgen Go tests likewise could not run because is absent. Generated snapshot artifacts were removed, and only the intended source file remains modified.
- Successfully reproduced the reported error. A temporary synthetic Go typedef declared
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.