Skip to content

Fix a bug where fields of aliased structs couldn't be accessed#41

Merged
MidnightDesign merged 1 commit into0.2.xfrom
field-access-on-struct-alias
Oct 14, 2025
Merged

Fix a bug where fields of aliased structs couldn't be accessed#41
MidnightDesign merged 1 commit into0.2.xfrom
field-access-on-struct-alias

Conversation

@MidnightDesign
Copy link
Copy Markdown
Contributor

foo:{bar: string}.bar worked, but foo:MyStruct.bar didn't.

`foo:{bar: string}.bar` worked, but `foo:MyStruct.bar` didn't.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where field access on aliased struct types was failing. The issue was that direct field access using array syntax didn't work for aliased types (e.g., foo:MyStruct.bar), while inline struct definitions worked correctly (e.g., foo:{bar: string}.bar).

  • Updated field access logic to use getFieldType() method instead of direct array access
  • Added proper error handling for unknown fields
  • Updated test assertion from assertSame to assertEquals for better object comparison
  • Added comprehensive test case covering aliased struct field access in complex expressions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/FieldAccess.php Fixed field access by using getFieldType() method and added error handling for unknown fields
tests/unit/ExpressionTest.php Added test case for aliased struct field access and updated assertion method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@MidnightDesign MidnightDesign merged commit ceae2b6 into 0.2.x Oct 14, 2025
25 checks passed
@MidnightDesign MidnightDesign deleted the field-access-on-struct-alias branch October 14, 2025 06:33
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