Conversation
Several scanner/parser helpers re-asserted a precondition their sole caller had already checked one frame up (e.g. _scan_basic_string re-checking cursor-at-'"' after scan_string just asserted it). These duplicate checks ran on every string, array, inline table, and header parsed. Document the precondition in a docstring instead of re-checking it, matching the codebase's existing convention that helpers below a boundary trust their signatures. No behaviour change; ~1.5-2.5% faster parsing measured via interleaved A/B benchmarking against bench_pyproject.py. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6506e10c-587d-48ba-9ea3-632ef0edcbf6
Four related bugs in the "clone an existing attached Table into an
AoT" family, all found after adding a fuzzer op that appends an
already-attached Table rather than always synthesising a fresh dict:
* Cloning a plain `[k]` section as a new AoT entry kept the `[k]`
header instead of rewriting it to `[[k]]` — `_clone_entry_slots`
only remapped a header's `entry` discriminator when the *source*
header already had one, so promoting a plain table to an entry
silently left `entry` as None.
* `_owner_aot_entry is not None` was used in several places as a
stand-in for "value is itself an AoT entry", but it's also true for
anything physically nested inside one (inline tables, implicit
sections, explicit nested sections). This crashed on inline tables
(no header to clone) and silently double-nested explicit sections.
Added `Container._is_own_aot_entry` to discriminate correctly.
* Cloning a dotted-key navigator view (e.g. the `a` in `t = {a.b=1}`)
crashed because it owns no CST of its own to clone; it now
synthesises fresh from its logical items like any other Mapping.
* Emptying an AoT reached only through dotted keys, itself nested
inside another AoT entry, crashed on an over-strict assert in
`_synthesise_header_then_insert_kv` that assumed a header could only
be synthesised in this shape during `reposition_install`; entry
removal reaches the same shape legitimately.
Each bug has a dedicated regression test in test_mutation.py, verified
to fail without its corresponding fix.
Also extends the mutation fuzzer (test_fuzz_mutation.py) with a
"clone_table" AoT op that appends an existing attached Table rather
than only ever synthesising fresh dict entries — this is what
surfaced all four bugs, and the existing tomli-vs-to_dict() oracle is
what actually catches them (the idempotence oracle alone would not,
since the buggy output is a stable self-consistent fixed point).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ac201ee3-8e8a-44ca-9d3a-001f6fdb4308
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.
No description provided.