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 understanding the repository structure and the issue. The issue is about a conflict between a constant named
Unknownin the discordgo Go package and Lisette's built-inUnknowntype. When generating bindings, the compiler sees the discordgo constantUnknownin a type position and throws a "value in type position" error.Let me explore the repository structure first.
Assistant
This is a Rust project. Let me explore the crates directory to understand the structure better.
The issue is about binding generation for Go packages. The
Unknowntype from Lisette's built-in types conflicts with a constant namedUnknownin the discordgo package. The binding generator should qualify or disambiguate imported names that shadow built-in types.Let me look at the relevant code.
Assistant
The binding generator is likely in the
bindgendirectory. Let me explore it.Assistant
The binding generator is a Go project. Let me look at the bindgen internal structure.
Assistant
Let me look at the convert directory, which likely handles the conversion of Go types to Lisette types.
Assistant
Let me search for "Unknown" in the bindgen codebase.
Assistant
Let me look at the semantic/resolve crate to understand the error.
Assistant
Let me look at the resolve module in semantics crate.
Assistant
Let me look at the passes directory
Assistant
Let me search for the "value_in_type_position" error in the codebase
Assistant
Let me look at the convert.rs to understand how the error is triggered
Assistant
Let me find the
resolve_type_namefunction to understand the resolution order.Assistant
Let me look at the
resolve_type_namefunction in checkerAssistant
Now let me look at
lookup_qualified_nameto understand the name resolution order.Assistant
Let me look at
lookup_qualified_namein checker/mod.rs line 325.Assistant
Now let me look at
store.get_typeto understand what it returns.Assistant
Let me look at
store.get_typeAssistant
Let me look at the DefinitionBody enum to understand value vs type definitions.
Assistant
Let me look at the DefinitionBody enum.
Assistant
Let me look at the bindgen emitter.
Assistant
Let me check how
resolve_type_nameis used in builtins.rs.Assistant
Let me look at the full Definition implementation to see if there's a method for checking if it's a type definition.
Assistant
Let me check the full Definition implementation for existing type checks.
Assistant
Let me check how
resolve_type_nameis used in patterns.rs to ensure my change won't break pattern matching.Assistant
Let me check the usage patterns.
resolve_type_nameis only called inconvert.rsandbuiltins.rs. Thebuiltins.rsusage is only for built-in prelude types, so filtering out values there would be safe.Now let me also check if there are tests that might validate this behavior:
Assistant
Now I understand the issue clearly. The fix should be in
resolve_type_name- when the resolved name is a Value definition (constant, variable, function), it should returnNone, allowing the fallback to prelude types likeUnknown.Let me verify my understanding by looking at the
resolve_type_namefunction one more time:Assistant
Let me check the imports at the top of mod.rs to see what's available.
Assistant
Now let me implement the fix. The issue is in
resolve_type_name- it should only return type definitions, not value definitions (constants, variables, functions). When a value definition like discordgo'sUnknownconstant shadows a prelude type, the function should returnNone, allowingresolve_type_with_arityto fall back to the prelude.Let me edit the `resolve_type_name
Assistant
Let me use the replace command instead
Assistant
Let me try a different approach with
Assistant
Now let me make the edit using
Assistant
Let me verify the change was applied correctly.
Assistant
Good. Now let me try to build the project to verify the change compiles.
Assistant
The build succeeded. Now let me run the tests to make sure nothing is broken.
Assistant
There are 2 test failures. Let me investigate them to understand if they are related to my change.
Assistant
Let me look at the failing test to understand what it expects.
Assistant
Let me also look at the second failing test.
Assistant
Let me check if my change affects the completion flow. Let me search for how completion resolves types
Assistant
Let me look at the completion code in the LSP
Assistant
Let me look at the completion code for enum variants.
Assistant
Let me look at the dot context detection and enum completion
Assistant
Let me check if these tests were already failing before my change by stashing and running them.
Assistant
Let me run the full test suite from before my change.
Assistant
Let me also check the second test without my change.
Assistant
Let me restore my changes and
Assistant
Let me look at the struct call resolution code
Assistant
Let me look at how goto-definition resolves the field in struct calls.
Assistant
Let me look at the goto_definition handler:
Assistant
Let me search for
lookup_definition_span:Assistant
Let me look at
lookup_definition_spanin definition.rs:Assistant
Let me look at
find_struct_field_span:Assistant
Let me look at how the TypeLevel dot context is used for completion:
Assistant
Let me debug the issue by running the failing test with more output:
Assistant
Let me see the full alias_target function:
Assistant
Let me search for how the analysis snapshot processes definitions, specifically using
resolve_type_nameor similar:Assistant
Let me search for where enum variants are added to module definitions:
Assistant
Let me search for how enum variant constructors are added as definitions:
Assistant
Let me look at
add_enum_variant_to_scope:Assistant
Let me look at how enum variants are registered as definitions in the store:
Assistant
Let me look at lines around 95-110 in types.rs:
Assistant
Let me look at how the LSP triggers analysis:
Assistant
Let me look at the analyze function:
Assistant
Let me double-check - revert my change and confirm the test passes:
Assistant
Let me revert, test, then re-apply:
Assistant
Let me run them individually
Assistant
Now let me re-apply my change and run the test
Assistant
Let me look at how dot access is inferred:
Assistant
Let me look at dot_access.rs inference:
Assistant
Let me look at how identifiers are inferred in the expression inference
Assistant
Let me look at how identifiers are resolved:
Assistant
Let me look at
lookup_type:Assistant
Let me look at `lookup_type
Assistant
Let me look at
resolve_definition_value_typeAssistant
Let me look at `resolve_definition_value_type
Assistant
Let me search for where
resolve_type_nameis called during type registration:Assistant
Let me look at the registration function to understand how types are registered:
Assistant
Let me look at
register_types_and_values:Assistant
Let me look at how type definitions are registered:
Assistant
Let me look at
populate_type_alias:Assistant
Let me look at
populate_type_aliasAssistant
Let me see the rest of
populate_type_aliasAssistant
Let me look at
collect_type_name_entriesto see what placeholder is created for enums:Assistant
I found the root cause of the test failure! The
register_type_namesfunction creates placeholder definitions withDefinitionBody::Valuefor ALL type names (including Enums, Structs, etc.). When type aliases are processed before the referenced types are fully populated,resolve_type_namefinds these placeholder Values and my change incorrectly filters them out.The proper fix is in
resolve_type_with_arity: when the resolved name is a Value definition, try the prelude first. Let me revert my change and apply the correct fix:Assistant
Now let me modify
resolve_type_with_arityinstead:Assistant
Let me check the imports in convert.rs:
Assistant
Now let me apply the fix using the Python script:
Assistant
Let me verify the change and run the tests:
Assistant
Let me build and test
Assistant
Good, build succeeds. Let me run the previously failing tests:
Assistant
Now the second test:
Assistant
Both tests pass now. Let me run the full test suite:
Assistant
Let me check if these tests were already failing before my change:
Assistant
Same number of failures (1576) - these are pre-existing. Let me restore my change:
Assistant
Good - the 1576 failures are pre-existing. Let me run the relevant test suites that might be affected by my change:
Assistant
All semantics tests pass. Let me run the LSP tests:
Assistant
All 502 LSP tests pass. Let me verify my final change:
Assistant
Let me clean up temporary files:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.