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 understand the issue:
- There's a programming language called Lisette that has a built-in type called
Unknown. - When binding to Go packages (like discordgo), if the Go package defines a constant also named
Unknown, it conflicts with Lisette's built-inUnknowntype. - The binding generator emits
Unknownin type positions, but the name resolves to the discordgo constant value instead of the Lisette type.
The fix should be in the binding generator or the compiler's name resolution - Lisette's built-in
Unknowntype should take precedence in type positions, or the binding generator should qualify/disambiguate imported names that shadow built-in types.Let me explore the repository structure first.
- There's a programming language called Lisette that has a built-in type called
Assistant
This is a Rust project. Let me explore more to find the relevant parts - the binding generator and the compiler's name resolution.
Assistant
Let me explore more - particularly the binding generator and the compiler's name resolution. Let me also look at the directory structure.
Assistant
There's a
bindgendirectory which is likely the binding generator. Let me explore it.Assistant
I need to make only one tool call at a time.
Assistant
Let me look at the emit directory and convert directory for the binding generator.
Assistant
The bindgen is written in Go. Let me look at the emitter to understand how it generates bindings and where "Unknown" is
Assistant
Let me see the context around line
Assistant
Let me look at the convert directory and the compiler's name resolution.
Assistant
Let me look at the types.go file to see how types are converted, and also look for "Unknown" in the converters.
Assistant
Let me look at the compiler's name resolution in the semantics
Assistant
Let me search for the resolver which handles name resolution.
Assistant
Let me look at the convert.rs file where the error is triggered
Assistant
Let me find the
classify_non_type_namefunction to understand how it worksAssistant
Let me look at the
classify_non_type_nameAssistant
Let me look at
resolve_type_with_arityto understand how names areAssistant
Let me look at
resolve_type_nameto understand how it resolvesAssistant
Let me search for the definition of
resolve_type_nameAssistant
Let me look at the
resolve_type_namefunction in the checker moduleAssistant
Let me look at
lookup_qualified_nameAssistant
Let me look at
lookup_qualified_namein the checker moduleAssistant
Let me look at
resolve_in_imported_moduleAssistant
Let me look at
resolve_in_imported_moduleAssistant
Let me look at
store.get_typeto understand what happens when a value is resolvedAssistant
Let me look at
get_typeAssistant
Assistant
Let me look at the builtins registration to understand how
Unknownis registeredAssistant
Let me look at the
DefinitionBodyenum to understand what qualifies as a type definitionAssistant
Let me search in the broader codebase
Assistant
Let me look at the DefinitionBody enum
Assistant
Now let me check if there are any other direct callers of
resolve_type_namethat might be affectedAssistant
Let me look at the context around line 68 in convert.rs
Assistant
Now I have a clear understanding of the issue. Let me look at the
resolve_type_namefunction and implement the fix.The problem: When
Unknownis used in a type position,lookup_qualified_nameresolves it to the discordgo constant (aValuedefinition), which then fails with "value in type position". The fix should be: inresolve_type_name, if the resolved definition is a value, returnNoneso that the prelude (which contains the built-inUnknowntype) can be tried.Assistant
Let me check what's already imported in this file (the checker/mod
Assistant
Now I understand the issue fully. Let me implement the fix in
resolve_type_name. When the resolved name refers to a value definition (like a constant), we should returnNoneso that the prelude can be tried insteadAssistant
Let me use the edit command to modify the file directly
Assistant
Let me use the proper syntax for the edit command
Assistant
I see the edit removed the function signature for
resolve_type_from_prelude. Let me fix this by adding back the missing function signatureAssistant
Let me verify the current state of the
resolve_type_from_preludefunctionAssistant
The
&selfparameter is missing! Let me fix thisAssistant
Now let me verify the complete change by looking at the diff
Assistant
The diff looks correct. Let me build the project to see if it compiles
Assistant
The code compiles. Now let me run existing tests to make sure nothing is broken
Assistant
Let me first check if these tests were already failing before my change
Assistant
Let me run the tests properly
Assistant
Let me also run the other test
Assistant
My change is causing these failures. Let me restore my change and investigate
Assistant
Let me look at these failing tests to understand what they do
Assistant
Let me look at the test to understand what it does
Assistant
Let me look at the goto_definition test
Assistant
Let me look at how struct calls resolve type names to understand the issue better
Assistant
Let me look at the dot access resolution to see how enum variants are resolved
Assistant
Let me look at the goto_definition implementation for struct fields
Assistant
Let me look at the goto_definition implementation
Assistant
Let me continue reading the goto_definition function
Assistant
Let me look at
resolve_struct_call_fieldto understand how it worksAssistant
Let me search for
resolve_struct_call_fieldin the whole codebaseAssistant
Let me look at the resolve_struct_call_field in the LSP definition.rs file
Assistant
Let me look at the exact test source and line numbers more carefully
Assistant
Let me look at the tests around this area to understand the full context
Assistant
Let me look at the
type_namefunctionAssistant
Let me look at the
type_namefunction in lsp/src/analysis.rsAssistant
Let me look at the struct call inference to understand the type of the expression
Assistant
Let me look at the
lookup_typefunction to see if it callsresolve_type_nameAssistant
Let me look at the
lookup_typefunctionAssistant
Let me look at how dot access completions work for enum variants
Assistant
Let me look at the completion handler
Assistant
Let me look at the
Assistant
Let me see more of the completion handler
Assistant
Let me look at
detect_dot_contextto see how it resolves the typeAssistant
Let me look at
detect_dot_contextAssistant
Let me look at
get_type_completionsAssistant
Let me look at
get_type_completionsAssistant
Let me look at
infer_struct_call_for_structto see what type it produces for the expressionAssistant
Let me look at `infer_struct_call
Assistant
Let me re-run the specific failing test to confirm it's failing due to my change
Assistant
Let me look at the
instantiatefunctionAssistant
Let me look at the
Assistant
Let me look at
lookup_definition_spanfunctionAssistant
Let me search properly
Assistant
Let me look at this function
Assistant
Let me check
find_struct_field_spanAssistant
Let me look at this function
Assistant
Let me stash my change and run the full test suite to see if those tests pass without my change
Assistant
Both tests pass without my change. Let me restore and investigate more
Assistant
Let me add some temporary debug logging to understand what's happening with my change
Assistant
Let me look at the
convert_to_typefunction to understand the full flowAssistant
Let me verify the current state of the file around the edit
Assistant
Let me run the semantics tests to see if my change breaks anything
Assistant
Let me run all tests to see the full picture
Assistant
Let me look at the
TestClientto understand how it worksAssistant
Let me look at the TestClient implementation
Assistant
Let me find the TestClient definition
Assistant
Let me look at Test
Assistant
Let me look at
wait_for_serverAssistant
Let me look at these methods
Assistant
Let me add temporary debug output to understand the test
Assistant
Let me add temporary debug output to see what's happening
Assistant
Now let me run the failing test to see the debug output
Assistant
Interesting!
Pointis being resolved as a VALUE. This is because struct constructors are registered as value definitions with the same name. Let me investigate how definitions are storedAssistant
Let me look at `get_definition
Assistant
Let me search for how struct definitions are registered and how constructors work
Assistant
Let me look at how struct definitions are iterated/
Assistant
Let me look at how struct definitions are registered in registration/mod.rs
Assistant
Let me search for where struct constructors are registered
Assistant
Let me look at
register_tuple_struct_constructorAssistant
Let me search for where the struct
Pointdefinition is registered in the moduleAssistant
Let me look around line 132
Assistant
Let me look for
register_file_value_definitionsAssistant
Let me look at
collect_type_name_entriesAssistant
Let me look at
collect_type_name_entriesAssistant
Let me look at
register_type_definitionsto see when type resolution happensAssistant
I found the root cause! The
collect_type_name_entriesfunction registers type placeholder entries asDefinitionBody::Valuewith the type pointing to itself (self-referencing). My change breaks this because it rejects all values before the self-referencing check inclassify_non_type_name.The fix needs to also handle the self-referencing case (constructors). Let me update the fix:
Assistant
Let me check if
unwrap_forallmethod exists onAssistant
Let me also check
get_qualified_idAssistant
Now let me build and test
Assistant
Now let me run all tests
Assistant
Let me check the
unwrap_forallmethod signature and how it's used inclassify_non_type_nameAssistant
Let me check the
get_qualified_idmethodAssistant
Let me check the Definition struct's
Assistant
Let me look at one of the failing spec tests to understand the error
Assistant
Let me find how to run these spec tests
Assistant
My change is causing too many issues. Let me revert and try a
Assistant
Let me try a different approach: modify
resolve_type_with_arityto check if the resolved name is a value and try the prelude before acceptingAssistant
The fix should be in
convert_to_type. Afterclassify_non_type_namedetermines it's a value, we should try the prelude:Assistant
Now let me modify the convert.rs to try the prelude when a value is found in type position
Assistant
I need to actually use the prelude type when it's found. Let me fix this
Assistant
Let me fix the logic properly - when prelude is found, use it instead of reporting error
Assistant
I see the issue with shadowing. Let me restructure using mutable variables:
Assistant
Let me look at the full context around the issue
Assistant
Let me revert the file and start with a cleaner approach
Assistant
Let me look at the exact original code
Assistant
Let me make a precise edit. I'll change the
classify_non_type_nameblock and make the bindings mutableAssistant
Let me build and test
Assistant
Now let me run all tests
Assistant
Let me revert and try a cleaner approach in
resolve_type_nameAssistant
Let me implement the fix in
resolve_type_namein checker/Assistant
Now let me implement the fix in
resolve_type_name:Assistant
I need to fix the missing function signature again. Let me add it
Assistant
Missing
store: &Store,parameter. Let me fix itAssistant
Now let me build and test
Assistant
Now let me run all tests
Assistant
The approach of modifying the compiler is causing too many side effects. Let me look at the binding generator instead - maybe we can fix it
Assistant
Let me look at the binding generator emitter to understand how types are emitted
Assistant
Let me look at the function that uses basicTypes and
Assistant
Let me look at how
LisetteTypeis constructed in the convert packageAssistant
Let me look at
basicToLisettefunctionAssistant
Let me look at the `basicToLisette
Assistant
Let me look at a specific test output to understand the failure
Assistant
Let me try a more targeted approach. Only redirect to prelude when the value definition is from an imported module, not the current
Assistant
Now let me implement the fix. Only redirect to prelude when the value is from an imported module
Assistant
Same issue: the function signature is broken. Let me fix it
Assistant
The function body is incomplete. Let me fix it
Assistant
There's an extra
}on line 528. Let me fix itAssistant
Now let me build and test
Assistant
Now let me run all tests
Assistant
Let me revert all changes and check the baseline
Assistant
Let me verify the baseline test passes
Assistant
The test
go_type_same_name_as_prelude_uses_go_methodswas already failing before my change! These spec test failures are pre-existing. Let me re-apply my fixAssistant
Let me check if there's a clean state and verify the baseline
Assistant
The many failures are from stale snapshot files. Let me clean them up and re-apply my fix
Assistant
Now let me run the baseline tests to confirm they
Assistant
The 1576 failures are pre-existing (not caused by my change). Let me re-apply my fix and verify only the same tests fail
Assistant
Now let me re-apply the
Assistant
Let me fix the function signature
Assistant
The function body is missing the variable declaration. Let me fix it
Assistant
There's an extra
}on line 528. Let me remove itAssistant
Now let me build and run tests
Assistant
The test results are identical to before my change: 3572 passed, 1576 failed (pre-existing failures). My fix introduces no regressions.
Let me verify the diff:
Assistant
Let me clean up any leftover 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.