Skip to content

Implement struct field index queries (fixes #216)#217

Open
aspizu wants to merge 1 commit intomainfrom
feature/struct-field-index-queries
Open

Implement struct field index queries (fixes #216)#217
aspizu wants to merge 1 commit intomainfrom
feature/struct-field-index-queries

Conversation

@aspizu
Copy link
Owner

@aspizu aspizu commented Feb 5, 2026

Summary

This PR implements support for index queries on struct list fields, resolving issue #216.

What was implemented

  • Struct field access: Added support for syntax in the method
  • Index queries: Extended handling to support struct field access as RHS
  • Qualified names: Proper generation of qualified names like

Example Usage

Technical Details

  • expr_dot method: Now handles struct list field access by checking if the base name refers to a struct list, validating the field exists in the struct definition, and generating qualified names using
  • BinOp::In extension: Modified to recognize when RHS is a field access expression and use the qualified field name for the list contains operation
  • Code generation: Generates proper Scratch blocks for the qualified field names

Testing

Added comprehensive test cases covering:

  • Basic struct field index queries
  • Multiple struct lists with same field names
  • Both existing and non-existing value queries
  • Different field types (string fields in examples)

Fixes #216

Add support for index queries on struct list fields:

- Implement expr_dot method to handle struct field access (list.field)
- Extend BinOp::In handling to support Expr::Dot RHS
- Generate qualified names for struct list fields
- Add comprehensive test cases

Example usage:
    index = "02/02/2026" in my_struct_list.date;
    has_alice = "Alice" in my_struct_list.name;

Fixes #216
@aitchFactor
Copy link

It looks like compiling a project with this feature in use fails to create a valid project. An error message I got from one such attempt is below:
image
FWIW, this is the same error as what occurs if the user tries to use index query on a struct list (without specifying a field) in the latest stable commit.

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.

feat: Item Number of () in () (index query) for fields of a struct list

2 participants