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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
The issue is that when the binding generator emits
Unknownin a type position, the name resolves to the discordgo constant valueUnknowninstead of the Lisette built-in type. Let me understand how the emitter works and how constants are emitted.Let me look at the whole emitter.go to understand the structure.
Assistant
Let me look at the Lisette compiler semantics to understand name resolution.
Assistant
Let me understand the resolve pass to see how
Unknownis resolved in type positions and how a constantUnknownwould shadow the built-in type.Let me look at the resolution logic.
Assistant
So
classify_non_type_nameis what determines if a name resolves to a value rather than a type. Let me look atresolve_type_with_arityandclassify_non_type_name.Assistant
Let me look at
lookup_qualified_nameto understand the resolution.Assistant
Let me look at the bindgen tests and how the binding generator handles name collisions.
Assistant
Let me look at the bindgen_test.go to understand how tests are structured, then look at how to reproduce. Let me also look at the convert/types.go to understand the
Unknownplaceholder.Assistant
Let me look at the convert/types.go to understand how
Unknownis generated as a type placeholder.Assistant
Let me check the prelude to confirm
Unknownis a prelude type.Assistant
Let me check the CHANGELOG and recent commits to understand the project's direction.
Assistant
Let me look at the full
convert_to_typefunction.Assistant
Let me look at builtins.rs to understand the builtin types.
Assistant
Let me look at existing tests around value-in-type-position to understand expected behavior.
Assistant
Let me look at the snapshots to understand the exact expected error messages.
Assistant
Let me look at the Converter struct and how it's set up.
Assistant
Let me check whether
prelude.qualification is used anywhere in generated files or syntax.Assistant
Let me check whether
prelude.qualification is valid in Lisette by looking at how prelude is set up as a module.Assistant
Let me check who calls
resolve_type_with_arityandresolve_type_name.Assistant
Let me look at the exact code around line 84 and the resolve_type_with_arity function.
Assistant
Let me check the
DefinitionBodyenum to understand how to check if a definition is a value.Assistant
Now I understand the issue. Let me reproduce it first with a test script to confirm my understanding of the resolution path. Let me look at how to run the semantics tests and create a reproduction.
Assistant
Let me check how
Unknownis restricted to.d.lisfiles and look at the harness for typedef tests.Assistant
Let me look at the test harness to understand how to write a reproduction test with typedef files.
Assistant
Let me look at the macros for go typedef assertions.
Assistant
Let me look at the pipeline and how go typedefs are registered.
Assistant
I now understand the test harness. I can write a temporary test that uses
infer_with_go_typedefswith a typedef that definespub const Unknown = 0and usesUnknownin a type position, then import that go module and reference it.Actually, the conflict happens within the typedef itself: the typedef defines both
pub const Unknown = 0AND usesUnknownas a type (e.g.pub var Logger: fn(Unknown) -> ()). When the typedef is type-checked/registered, theUnknownin the type position resolves to the constant. So I need the typedef to be registered and have the conflict resolved during registration.But wait — when does the typedef get type-checked? The typedef is registered via
parse_and_register_go_module. Does that run inference on the typedef's types? The error in the issue occurs "during binding resolution". Let me check whetherparse_and_register_go_modulerunsconvert_to_typeon the typedef's annotations.Actually, the error in the issue is from
lis runwhich compiles the user's program that importsgo:github.com_bwmarrin_discordgo. The typedef is registered and its type annotations are converted via . So the error occurs during registration/inference of the typedef.Assistant
Let me look at
register_types_and_valuesand the registration flow.Assistant
Let me look at
register_valuesto see when variable type annotations are converted.Assistant
Let me look at
register_variable_declarationandextract_signature_parts.Assistant
I now have a clear understanding. Let me first build the project, then write a reproduction test.
Assistant
Now let me write a reproduction test. Let me check the tests crate structure.
Assistant
Now let me create a temporary reproduction test file.
Assistant
Let me check how the infer test module includes files.
Assistant
I need to add my temp file as a module. Let me add it temporarily.
Assistant
I've reproduced the error. Now let me implement the fix in
resolve_type_with_arity. Let me view the function once more and edit it.Assistant
Now let me add the
is_value_definitionhelper method. Let me view the area afterresolve_type_with_arity.Assistant
Now let me re-run the reproduction test.
Assistant
The fix works. Let me expand my reproduction test to cover the issue's exact scenarios and edge cases.
Assistant
The first test failed with
not_found_in_module— likelyVarArgsisn't a known type. Let me check.Assistant
VarArgsis a prelude type. So why is there anot_found_in_moduleerror? Let me look at the full error. The error code isresolve.not_found_in_module— this is aboutui.Unknownorui.UnknownLocalenot found? Let me see the full output. Let me re-run and print all errors.Assistant
The typedef has invalid syntax (
pub type Locale int). Let me fix the test to use valid Lisette syntax.Assistant
All edge cases pass. Now let me run the broader test suites to ensure I didn't break anything. Let me run the relevant test categories.
Assistant
There are 5 emit test failures. Let me check if they're pre-existing or caused by my change. Let me temporarily revert the convert.rs change to test.
Assistant
The emit failures are pre-existing (they fail even with my change stashed). They're unrelated to my fix. Let me clean up the insta artifact files and run the infer + error tests specifically.
Assistant
All infer tests pass. Now let me run the UI error tests (especially the
infer_not_a_type_*ones).Assistant
All UI error tests pass. Let me run the entire suite test to confirm only the pre-existing emit failures remain.
Assistant
That's a lot of emit failures. Let me check whether these are pre-existing by stashing my change and comparing.
Assistant
Even on the baseline (my change stashed),
spec::emithas 1422 failures andspec::buildgenerates many artifacts — these are clearly pre-existing environment-related failures (likely Go toolchain version differences affecting emitted Go output). Let me verify the nature of these failures and confirm my change doesn't add new ones. Let me clean up artifacts first.Assistant
With my change,
spec::emitshows the identical count (5 passed, 1422 failed) as the baseline — so my change adds zero new emit failures. Let me confirm the nature of one pre-existing failure to verify it's environmental.Assistant
The diff is purely formatting (tabs vs spaces) —
gofmtisn't being applied in this sandbox. This confirms the emit/build failures are environmental and unrelated to my change. Let me verify gofmt is the cause.Assistant
goisn't installed in this sandbox — confirming all emit/build snapshot failures are purely formatting (gofmt) differences, entirely environmental and unrelated to my change.Let me clean up the artifacts and verify the prelude types relevant to my fix.
Assistant
prelude.Unknownandprelude.Neverexist as type definitions, so my fix covers them. Let me check howUnknownis restricted to.d.lisfiles in regular user code, to ensure my fix doesn't inadvertently allowUnknownin user.lisfiles.Assistant
Let me check the enforcement of
Unknownnot being usable in regular.lisfiles.Assistant
My fix is consistent:
Unknownin a type position always resolves to the preludeUnknowntype regardless of a same-named constant. Theis_lischecks and unification still preventUnknownmisuse in regular.lisfiles. Let me run the remaining spec test categories (lint, etc.) excluding the environmentally-broken emit/build.Assistant
Lint and format tests pass. Let me run the semantics crate's own unit tests.
Assistant
All tests pass. Now let me clean up my temporary test file and the mod.rs change.
Assistant
Only
convert.rsis modified. Let me review the final diff.Assistant
The diff is clean and minimal. Let me verify the build is clean with no warnings and run a final confirmation of the reproduction (re-adding the temp test briefly to confirm the fix still works after cleanup).
Actually, let me write a quick standalone check using a temporary test once more to be 100% sure the fix resolves the exact issue scenarios, then remove it.
Assistant
The fix resolves the exact issue scenarios. Let me do a final verification of the repository state.
Assistant
The repository is clean — only
convert.rsis modified. Let me run the infer and UI error suites one final time to confirm nothing is broken after cleanup.Assistant
All 1884 infer + UI error tests pass (the count dropped by exactly 5, matching the 5 temp tests I removed — confirming no regressions). Let me do a final review of the change.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.