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 inspect the repository structure and search for the resolver’s type/value namespace handling, built-in
Unknowndefinition, and Go binding generation. This will identify whether the robust fix belongs in name resolution or generated bindings, and where relevant tests live. - Assistant
ripgrepis unavailable, so I’ll use recursivegrepand enumerate crate/test directories. I’m looking especially for the diagnostic code and symbol-table lookup order, because allowing a built-in type to win specifically in a type context is likely more general than special-casing discordgo. - Assistant
The checked-in standard library already contains an identical collision in
go/constant.d.lis(pub const Unknownplus signatures usingUnknownas a type), making it a convenient local reproducer without downloading discordgo. I’ll now locate resolver implementation and semantic test harnesses, then run or add only a temporary reproduction as required (not repository tests). - Assistant
I found resolution at
checker/registration/convert.rs. I’ll inspect that conversion path, scope APIs, and built-in registration to understand how a syntax name becomes either a value binding or built-in type and preserve intentional shadowing behavior for all other names. - Assistant
The converter deliberately resolves a name first, then diagnoses if the selected definition is a value. The key is
resolve_type_with_arity/resolve_type_name; I’ll inspect those definitions and registration ordering. I’ll also inspect predeclared-shadowing checks, since they may encode the intended language rule and reveal whether generated.d.lisfiles are treated differently from user source. - Assistant
A comment confirms
Unknownis semantically special, while only Go emitter namesany/comparableare prohibited. I’ll read the exact lookup implementation and classification logic before changing anything, then use the CLI against a tiny temporary package definingpub const Unknownand a function parameter typedUnknownto capture the current diagnostic. - Assistant
resolve_type_with_arityalready falls back to the prelude when a local symbol’s generic arity differs, but same-arity value collisions remain selected. The general namespace-correct rule is: in a type position, if the local candidate is not a type and an identically named prelude type with matching arity exists, use that type; still diagnose ordinary values where no valid type candidate exists. Before implementing, I’ll verify current behavior via a temporary standalone.lisfile and inspect test harness APIs for a focused post-change check without modifying tests. - Assistant
The reproduction emits all three reported
resolve.value_in_type_positionerrors. I’ll modify onlyresolve_type_with_arity: unqualified value definitions will no longer hide a matching prelude type in a type context. User-defined types (including a genuine type namedUnknown), generic parameters, qualified names, and values without a same-name prelude type retain existing behavior. - Assistant
The reported diagnostics are gone; remaining errors are expected because generated-style top-level
pub vardeclarations are invalid in a normal.lissource file. I’ll strengthen verification in two ways: check an actual.d.lismodule importing the built-ingo/constantpackage (which has the same collision), and exercise edge cases ensuring ordinary value-in-type diagnostics still fire and genuine type shadowing still works. Then I’ll run focused semantics tests and the full workspace suite if feasible. - Assistant
The real
go:go/constantimport now checks cleanly, and an unrelated constant used as a type still producesresolve.value_in_type_position, confirming the fallback is narrowly conditioned. The synthetic project manifest format was wrong, so I’ll correct it from repository examples and rerun that direct generated-binding fixture. I’ll also run semantics/spec tests; afterward I’ll evaluate whether the closure-based implementation triggers lint or borrow issues under Clippy. - Assistant
The semantics unit suite passes. The integration package name differs from my guess, and the synthetic module directory does not match dependency locator conventions; neither affects the successful real stdlib reproduction. I’ll identify the test package name and use the test harness’s existing Go-typedef mechanism through its suite. I’ll also inspect bindgen’s existing reserved-name logic: if it already tracks names requiring qualification, a generator-level fix might be more appropriate, but resolver fallback remains necessary for checked-in/std library collisions.
- Assistant
The bindgen emits
Unknownintentionally and has no syntax for qualifying prelude types, so resolver disambiguation is the appropriate layer. I’ll run the integration inference suite, including existing value-in-type-position cases, then Clippy on semantics. I’ll also run bindgen’s Go tests because this behavior originates in generated signatures, even though no Go code changed. - Assistant
All 1,276 inference tests and Clippy pass. Go is not installed in this environment, so bindgen tests cannot run; the Rust CLI had reported Go as unavailable in e2e detection as well. I’ll now verify two final edge cases: a genuine user-defined type named
Unknowncontinues to shadow the prelude type, and qualified value names do not silently fall back. Then I’ll run the complete non-e2e integration suite (about 5,000 tests), inspect the final diff/status, and submit if clean. - Assistant
The full suite’s inference/checking portions passed, but snapshot-based emit/build tests failed because this checkout lacks their accepted snapshot artifacts, causing Insta to create many untracked
.snap.newfiles. This is an environment/repository-fixture issue rather than a code regression; I’ll remove every generated.snap.newfile immediately (tests must not be changed), then run the existing UI error suite, whose snapshots are present and specifically cover value-in-type diagnostics. The attempted genuine type shadow confirms Lisette already forbids shadowing prelude types, so the relevant supported edge case is value/type disambiguation exactly as implemented.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.