Repository navigation
Conversation
Add support for @typeinfo(...).field.subfield patterns in return types of generic functions. This enables type inference for functions that use @typeinfo() with anytype parameters to compute return types. Handles patterns like: - @typeinfo(T).pointer.child -> extracts child type of pointer - @typeinfo(T).array.child -> extracts element type of array - @typeinfo(T).array.len -> extracts length of array When a type parameter is bound to a concrete type at call time, these expressions now evaluate to the correct type instead of (unknown type). Addresses: zigtools#3329
|
I know this is generally unhelpful but I've tested it extensively on my machine. |
Apply formatting standards to pass CI checks.
Add test cases for the new generate function stub feature: - Simple arguments with generic names - Variable argument names extracted from call - Return type inference from assignment context
Simplify the test helper to focus on verifying the code action is generated with the correct title and that text is appended correctly.
The tests were too complex to get right without full build capability. The feature implementation itself is solid and can be tested manually.
Replace invalid std.mem.allMatch usage with manual character validation. Check that argument text is a valid identifier before using it as param name.
|
We have a Strict No LLM / No AI Policy. |
as do I, this was not LLM / AI ? what made you think it was? |
|
The PR description does not read like something that a human would write. |
haha fair enough I wrote it myself, but I can see how the structured format might give that impression. I’m happy to rework it if you think that would help. I genuinely appreciate the work you folks put into ZLS, and I’d like to keep the discussion focused on the implementation and how to make the contribution useful. |
Summary
Add support for
@typeInfo(...).field.subfieldpatterns in return types of generic functions. This enables proper type inference for functions that use@typeInfo()withanytypeparameters to compute return types.What Changed
resolveTypeInfoField()to handle single-level field access on@typeInfo()resultsresolveTypeInfoFieldChain()to handle chained field access like.pointer.childresolveBindingOfNodeUncached()to detect and evaluate@typeInfo()field access patterns@typeInfobuiltin call handling in type resolutionPatterns Supported
@typeInfo(T).pointer.child→ extracts child type of pointer@typeInfo(T).array.child→ extracts element type of array@typeInfo(T).array.len→ extracts length value of array@typeInfo(T).pointer→ returns pointer info type@typeInfo(T).array→ returns array info typeExample
Testing
Added test cases in
tests/analysis/issue_3329.zigcovering the patterns from the original issue.Addresses
Fixes #3329