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 start by exploring the repository structure to understand the codebase and find the relevant files.
Assistant
So the bindgen generates
Unknownas a Lisette type. The issue is that the discordgo package defines a constant namedUnknown, which conflicts. Let me understand the flow better. The bindgen generates.d.lisfiles. Let me look at the emitter and how constants are generated.The issue is: when Lisette generates bindings for discordgo, a constant named
Unknownis emitted. Then when function signatures useUnknown(the built-in type), the resolver finds the discordgo constantUnknowninstead.Let me look at how the bindings are emitted and how the constants are generated.
Assistant
Let me look at the compiler/resolver side to understand how
Unknownis defined as a built-in type.Assistant
Now let me understand where
Unknownis registered in the store. Let me look at how built-in types are defined.Assistant
Let me find where the
Unknowntype is defined in the prelude.Assistant
Let me look at the resolve pass and the
value_in_type_positionerror.Assistant
Let me look at
resolve_type_nameandresolve_type_from_prelude.Assistant
Let me look at
lookup_qualified_nameto understand the resolution order.Assistant
Let me look at the predeclared_shadowing pass to understand existing handling.
Assistant
Let me look at the existing tests for
value_in_type_positionand resolution to understand what might break.Assistant
Let me examine the prelude for
Noneand how the snapshot tests behave.Assistant
So
Noneis an enum variant, not a type. There's noprelude.Nonetype (it'sprelude.Option.None). Soresolve_type_from_prelude("None")would look forprelude.Nonewhich doesn't exist as a type. So that test relies on the variant being resolved throughlookup_qualified_name.Wait, let me re-examine.
resolve_type_name("None"):lookup_qualified_name(store, "None")— checks current module (noNone), checks unprefixed imports. Is prelude an unprefixed import? Probably yes (the prelude is always imported unprefixed). Let me check. If prelude is imported unprefixed, thenlookup_qualified_namewould findprelude.Option.None(a variant definition, which is a value).
Actually wait, the prelude
Noneis an enum variant. Is it stored as a definitionprelude.Option.None? Let me check how enum variants are stored.Hmm, this is getting complicated. Let me look at
infer_not_a_type_unit_variant_prelude.snapto see what error it expects.Assistant
Let me find which names are prelude types (so I understand the scope of a compiler fallback).
Assistant
Let me look at the bindgen tests structure to understand testing.
Assistant
Let me check if generated typedefs ever use
prelude.qualification.Assistant
Let me check where
type_unknownis used, sincebuiltin_qualified_nameuseslookup_qualified_namewhich could be affected by the collision.Assistant
type_unknownis defined but not used anywhere else (only defined in builtins.rs). Let me double-check by searching the whole crate.Assistant
Let me check the callers of
resolve_type_with_arityandresolve_type_name.Assistant
Let me verify how the prelude module is identified and whether
prelude.Unknownis accessible viastore.get_type.Assistant
Let me understand the test infrastructure and how to run things.
Assistant
Let me look at the test harness to understand how to write a reproduction test for typedef files with constants. Let me look at the suite.rs and the _harness directory.
Assistant
Let me find existing usages of
infer_with_go_typedefsto model a reproduction.Assistant
Let me look at the
InferResultassertion methods.Assistant
Let me look at how the spec tests are organized so I can add a temporary reproduction test.
Assistant
Let me look at the harness macros to find the simplest reproduction path.
Assistant
Now I have a good understanding. Let me create a temporary reproduction test that mimics the discordgo scenario.
Assistant
I've reproduced the issue. Now let me carefully check
store.get_typeto ensure my fix won't accidentally affect enum variants likeNone.Assistant
Let me check how enum variants are registered to understand if
prelude.Noneis a definition key.Assistant
Let me look at how enum variants are registered as definitions to understand the qualified name. Let me look at registration/mod.rs around the Enum handling.
Assistant
Let me look at
populate_enumto see how variants are registered (qualified names).Assistant
The fix is safe for
None/Some(they're variants, not types, soclassifystill flags them). Let me check whether any existing test uses a local value named like a prelude type in a type position expecting an error.Assistant
Let me check the bindgen testdata for constants that might shadow prelude type names.
Assistant
Let me check if any stdlib typedef defines a constant named exactly
Unknown(which would now resolve differently with the fix).Assistant
The stdlib
go/constantpackage definespub const Unknown: Kind = 0. Let me check if that file also usesUnknownas a type — this would be the same bug in the stdlib!Assistant
This is the exact bug in the stdlib!
go/constant.d.lishaspub const Unknown: Kind = 0AND usesUnknownas a type inMake(x: Unknown)andVal(...) -> Unknown. Let me verify how this stdlib typedef is named/loaded.Assistant
Let me check how stdlib go typedefs are loaded and the module id formation.
Assistant
Let me check how tests import go stdlib packages like
go/constant.Assistant
Let me update my repro test to also verify the bug with the real stdlib
go/constantpackage.Assistant
Interesting — the stdlib
go/constantdoes NOT produce an error with the simpleinferharness. Let me check the pipeline to understand whether go modules are actually inferred.Assistant
Let me look at
parse_and_register_go_moduleto understand registration order.Assistant
Let me look at
register_types_and_valuesto understand registration order (types vs values).Assistant
Let me look at
register_valuesto see if it converts function signature types during registration.Assistant
Let me check whether
go/constantis actually in the stdlib common map (to understand why my stdlib test showed no errors).Assistant
Let me check
extract_signature_partsandregister_variable_declarationto understand when types are resolved.Assistant
Key finding: in
extract_signature_parts, errors emitted during signature conversion are truncated (self.sink.truncate(before)). Sopub fnsignatures silently getType::ErrorforUnknown, whilepub vardeclarations report the error. My fix inresolve_type_with_arityhandles both. Let me apply the fix.Assistant
Now let me run my reproduction tests to confirm the fix.
Assistant
The custom test now passes with no errors. Let me verify the stdlib
go/constantsignatures resolveUnknownto the proper type (notType::Error). Let me write a stricter check using the emit harness.Assistant
Let me verify the emitted Go code is correct for the custom typedef case (that
Unknownresolves to the opaque type, notType::Error).Assistant
The custom typedef (both
pub varandpub fn) now infers and emits without errors. Now let me run the broader test suites to check for regressions. First the semantics unit tests.Assistant
Semantics lib tests pass. Now let me run the big test suite.
Assistant
1576 failures — that's a lot. Let me investigate whether these are pre-existing or caused by my change. Let me look at a specific failure first.
Assistant
The test name filter didn't match because of the path. Let me check the failing test names. The output listed test names like
spec::emit::types::tuple_struct_method_self_accessetc. but those might be passing. The "FAILED" summary says 1576 failed. Let me find which tests failed by running with a filter that captures failures. Let me run a single known test properly.Actually the issue is the test path uses
::and the filter needs exact module path. Let me run a specific emit test.Assistant
This is a user-written test using
Unknownin a regular.lisfile. The diff is confusing — let me look at the actual snapshot file to understand the before/after.Assistant
The only difference is a blank line — not related to my fix! This suggests pre-existing snapshot staleness. Let me verify by reverting my fix and checking if this test still fails.
Assistant
This confirms the 1576 failures are pre-existing (blank-line snapshot staleness in this environment), NOT caused by my fix — the test fails identically with my fix reverted. Let me clean up the generated
.snap.newjunk files and compare failure counts with/without my fix usingINSTA_UPDATE=noto avoid polluting the repo.Assistant
Now let me capture the failing test names WITH my fix applied (using
INSTA_UPDATE=noto avoid generating.snap.newfiles), then compare against the baseline without my fix.Assistant
The grep didn't capture anything because the FAILED lines have a different format (they're listed under "failures:" section without the "spec::" prefix at the start of line, or with leading spaces). Let me capture the test result summary line and the failure list differently.
Let me run and capture the summary and the failure list. The failures are listed after "failures:" as
spec::emit::.... Let me grep for lines starting with spaces thenspec::and containingFAILED— actually the FAILED appears in the per-test output. Let me just capture the summary numbers.Let me capture the "test result:" line and also the list under "failures:".
Assistant
Let me capture the full failure list WITH my fix, then WITHOUT, and diff them.
Assistant
Without my fix: 1577 failures. With my fix: 1576 failures. So my fix fixes one test and breaks none! Let me find which test differs.
Assistant
The only difference is my temporary repro test (which my fix correctly resolves). My fix breaks zero existing tests — the 1576 failures are pre-existing blank-line snapshot staleness in this environment. Let me confirm the blank-line nature on a build snapshot to be 100% sure it's unrelated to type resolution.
Assistant
This confirms the pre-existing failures are environment-related Go formatting differences (
gofmtspacing/indentation), present with and without my fix — completely unrelated to type resolution.Summary so far: My fix breaks zero existing tests (verified by diffing failure lists: 1577 without fix → 1576 with fix, the only difference being my temporary repro test which the fix correctly resolves).
Let me verify the relevant infer error-snapshot tests specifically still behave correctly (these are most related to my change).
Assistant
All
infer_not_a_typetests pass, includinginfer_not_a_type_unit_variant_prelude(which usesNone). Let me also run the shadowing-related tests.Assistant
These are emit/build snapshot tests failing due to the pre-existing gofmt formatting issue. Let me confirm
prelude_type_shadowing_struct_and_methodswas already failing before my fix (not newly broken).Assistant
Confirmed pre-existing. Let me run the full UI error-snapshot suite (no gofmt involvement, most relevant to my change).
Assistant
All 608 UI error snapshot tests pass. Let me run the infer spec tests (no gofmt involvement).
Assistant
All 1278 infer spec tests pass. My fix is verified correct with zero regressions. Now let me clean up my temporary test files.
Assistant
Now only my
convert.rschange remains. Let me review the final diff.Assistant
The diff is clean and minimal. Let me run clippy on the semantics crate to ensure no lint warnings (the repo enforces
-D warnings).Assistant
Clippy passes cleanly. Let me do a final end-to-end verification by re-creating the reproduction test, confirming the fix, then removing it.
Assistant
The final verification passes —
assert_no_errors()succeeds. Now let me clean up the temporary test.Assistant
The repository is clean with only my fix remaining. Let me do a final check for any leftover temp/snapshot files.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.