fix: enforce inline table and static array immutability#7
Merged
dereuromark merged 1 commit intomasterfrom Mar 25, 2026
Merged
Conversation
TOML spec requires that inline tables and static arrays (arrays defined via = [...]) are immutable and cannot be extended after definition. Changes: - Add static array tracking to reject extending array elements via table headers - Check sealed inline tables in openTable/openArrayTable - Track sealed tables within inline table scope for nested immutability - Properly reject dotted key extensions of inline tables and static arrays This fixes 5 toml-test invalid cases: - array/extending-table.toml - inline-table/overwrite-02.toml - inline-table/overwrite-07.toml - inline-table/overwrite-08.toml - inline-table/duplicate-key-03.toml Compliance: 98.1% invalid tests passing (TOML 1.1)
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.
Summary
TOML spec requires that inline tables and static arrays (arrays defined via
= [...]) are immutable and cannot be extended after definition. This PR enforces that constraint.Changes
staticArraystracking to reject extending array elements via table headersopenTable/openArrayTablebefore traversingsetNestedValueto accept scope-local sealed tables and static arraysFixed Cases
array/extending-table.tomla = [{}]then[a.b]now rejectedinline-table/overwrite-02.tomla = {}then[a.b]now rejectedinline-table/overwrite-07.toml{ inner.table = [{}], inner.table.val = "x" }now rejectedinline-table/overwrite-08.toml{ inner = {}, inner.cat = "x" }now rejectedinline-table/duplicate-key-03.tomlCompliance
The 9 remaining failures for TOML 1.1 are strict TOML 1.0 tests for features that 1.1 relaxes (multiline inline tables, trailing commas,
\xHHescapes, optional seconds).