Skip to content

Detect duplicate keys and overwrites in inline tables - #100

Merged
gongo merged 2 commits into
masterfrom
gh-90
Mar 15, 2026
Merged

Detect duplicate keys and overwrites in inline tables#100
gongo merged 2 commits into
masterfrom
gh-90

Conversation

@gongo

@gongo gongo commented Mar 15, 2026

Copy link
Copy Markdown
Owner

close #90

- Ran 680 tests, 620 results as expected, 60 unexpected
+ Ran 680 tests, 629 results as expected, 51 unexpected

gongo and others added 2 commits March 15, 2026 10:49
Add key-path tracking and 4-step validation to `toml:read-inline-table`:

Three tracking lists are maintained across the while loop:
- defined-paths: leaf paths that have been assigned a value
- implicit-paths: intermediate paths created by dotted keys
- inline-table-paths: paths whose value is an inline table (alist)

Validation steps (executed in order before storing each key-value):

1. Exact duplicate: full-path already in defined-paths
   e.g. {b=1, b=2}
2. Implicit table overwrite: full-path is a proper prefix of
   an existing defined-path (would destroy children)
   e.g. {b.c=1, b=2}
3. Inline table immutability: a proper prefix of full-path is
   in inline-table-paths (TOML spec forbids extending inline tables)
   e.g. {inner={dog="best"}, inner.cat="worst"}
4. Nesting into scalar: a proper prefix of full-path is in
   defined-paths but not in implicit-paths or inline-table-paths
   e.g. {b=1, b.c=2}

Steps 1/2 check defined-paths (any value type), while step 3
specifically checks inline-table-paths (alist values only).
Step 4 catches the reverse direction of step 2 (child under scalar).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gongo
gongo merged commit 158704c into master Mar 15, 2026
8 checks passed
@gongo
gongo deleted the gh-90 branch March 15, 2026 10:23
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.

[toml-test compliance] Detect duplicate keys in inline tables

1 participant