Skip to content

Conversation

@xav-db
Copy link
Member

@xav-db xav-db commented Dec 11, 2025

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:

  • Added closure_param_name field to Traversal and ReturnValueStruct to store the actual HQL closure parameter (e.g., e from entries::|e|)
  • Modified traversal validation to tag both main and nested traversals with the closure parameter name from the HQL syntax
  • Updated query generation to use the explicit closure_param_name instead of string manipulation heuristics like trim_end_matches('s')
  • Removed logic that attempted to resolve _ and val placeholders by guessing the iteration variable
  • Added test case user_test_5 demonstrating closure parameters with nested traversals (entries::|e|{ entryID: e::ID, ... })

Important Files Changed

File Analysis

Filename Score Overview
helix-db/src/helixc/analyzer/methods/traversal_validation.rs 5/5 added closure parameter name tracking to main traversal and nested traversals
helix-db/src/helixc/analyzer/methods/query_validation.rs 5/5 threaded closure_param_name through ReturnValueStruct creation calls
helix-db/src/helixc/generator/return_values.rs 5/5 added closure_param_name field to ReturnValueStruct and updated constructors
helix-db/src/helixc/generator/traversal_steps.rs 5/5 added closure_param_name field to Traversal struct for tracking HQL closure parameters
helix-db/src/helixc/generator/queries.rs 5/5 replaced heuristic closure variable resolution with explicit closure_param_name tracking

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(...)
Loading

@xav-db
Copy link
Member Author

xav-db commented Dec 11, 2025

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants