Skip to content

Reprint the key type of an array shape's unsealed type before its value type - #357

Merged
ondrejmirtes merged 1 commit into
2.5.xfrom
fix-unsealed-key-reprint
Dec 1, 2026
Merged

ondrejmirtes merged 1 commit into
2.5.xfrom
fix-unsealed-key-reprint

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

The format-preserving printer reprints the subnodes of a node in the order of its properties, and ArrayShapeUnsealedTypeNode declared $valueType before $keyType. Reprinting an unchanged array{a: int, ...<string, int>} produced array{a: int, ...<string, intstring, int>}, which does not parse. The same happened when only the key or the value type changed.

The fix declares $keyType first, in the order of the source. The constructor signature is unchanged. Tests for an unchanged keyed unsealed type, with and without other items, and for a changed key type and a changed value type are added to dataPrintFormatPreserving.

…ue type

The format-preserving printer reprints the subnodes of a node in the order of its properties,
ArrayShapeUnsealedTypeNode declared the value type first. An unchanged ...<string, int> was printed as
...<string, intstring, int>.

Amp-Thread-ID: https://ampcode.com/threads/T-01a22c96-9e21-771f-9a29-4627539ba301
@ondrejmirtes
ondrejmirtes merged commit 6ff7128 into 2.5.x Dec 1, 2026
64 of 67 checks passed
@ondrejmirtes
ondrejmirtes deleted the fix-unsealed-key-reprint branch December 1, 2026 11:20
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.

1 participant