fix (hql): closure fixes #748
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greptile Overview
Greptile Summary
This PR fixes closure parameter handling in HQL query compilation by explicitly tracking closure parameter names instead of using heuristics.
Key changes:
closure_param_namefield toTraversalandReturnValueStructto store the actual HQL closure parameter (e.g.,efromentries::|e|)closure_param_nameinstead of string manipulation heuristics liketrim_end_matches('s')_andvalplaceholders by guessing the iteration variableuser_test_5demonstrating closure parameters with nested traversals (entries::|e|{ entryID: e::ID, ... })Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant HQL as HQL Query (entries::|e|) participant TV as traversal_validation participant GT as Traversal struct participant QV as query_validation participant RV as ReturnValueStruct participant QG as queries.rs (codegen) HQL->>TV: Parse closure with identifier "e" TV->>GT: Set closure_param_name = Some("e") TV->>GT: Tag nested_traversals with closure_param_name GT->>QV: Pass traversal with closure info QV->>RV: Create ReturnValueStruct with closure_param_name RV->>QG: Generate Rust code QG->>QG: Use closure_param_name for variable reference Note over QG: Instead of guessing with trim_end_matches('s'),<br/>use explicit "e" from HQL syntax QG->>QG: Generate: |e| e.id(), e.get_property(...)