core: (assembly format) fix optional typed attribute parsing - #6311
Open
lowbyteguy wants to merge 1 commit into
Open
core: (assembly format) fix optional typed attribute parsing#6311lowbyteguy wants to merge 1 commit into
lowbyteguy wants to merge 1 commit into
Conversation
An optional attribute variable with a unique typed base parsed via `TypedAttribute.parse_with_type`, which has no optional counterpart and raises instead of returning None. In an optional group such as `($index^)? `of` ...` the absent case therefore failed with "Expected integer literal" rather than skipping the group. Backtrack to the attribute's start position and return None when `parse_with_type` raises, matching the optional contract of the sibling `AttributeVariable.parse_attr` implementations. Adds a regression test for an optional `IntegerAttr` property in an optional group, present and absent.
Member
|
Hi, sorry for the delay in reviewing. I don't think this is the right approach. We would want to make more fundamental changes to the assembly format infrastructure, more closely mirroring the existing |
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.
Closes #5562.
An optional attribute variable whose constraint pins a unique typed base is parsed through
TypedAttribute.parse_with_type, which has no optional counterpart and raises rather than returningNone. So in an optional group like($index^)? `of`, the absent case failed withExpected integer literalinstead of skipping the group — this is what brokepdl_interp.get_operands' assembly format.TypedAttributeVariable.parse_attrnow backtracks to the attribute's start position and returnsNonewhen the parse fails in the optional case, matching the optional contract the siblingAttributeVariableimplementations already honour.Regression test added in
tests/irdl/test_declarative_assembly_format.pyalongside the existing optional-property tests, covering both the present and absent forms; it fails onmainand passes with the fix.