Fix a bug where fields of aliased structs couldn't be accessed#41
Merged
MidnightDesign merged 1 commit into0.2.xfrom Oct 14, 2025
Merged
Fix a bug where fields of aliased structs couldn't be accessed#41MidnightDesign merged 1 commit into0.2.xfrom
MidnightDesign merged 1 commit into0.2.xfrom
Conversation
`foo:{bar: string}.bar` worked, but `foo:MyStruct.bar` didn't.
There was a problem hiding this comment.
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
assertSametoassertEqualsfor 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.
rieschl
approved these changes
Oct 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
foo:{bar: string}.barworked, butfoo:MyStruct.bardidn't.