Repository navigation
ci: match tuple variants in the CLI command-reference guard - #807
Merged
Merged
Conversation
The follow-up noted on NVIDIA#803: "the variant regex skips tuple variants (none exist today); extending it closes the one silent hole." The pattern was `^ {4}([A-Z][A-Za-z0-9]*)\s*[{,]?\s*$`, which requires the line to end after an optional `{` or `,`. A tuple variant carries its fields on the same line -- `Profile(String),` -- so it matched nothing and the subcommand was never required to appear in the book's table. Silent, which is the bad direction for a guard: a missed variant does not fail, it simply stops being checked. It now accepts the identifier followed by `{`, `(`, `,` or end of line, which covers all three variant shapes. The 4-space indent is what separates variants from everything else in the block -- doc comments start with `/`, attributes with `#`, a body's closing brace with `}`, and a variant's own fields are indented deeper -- so nothing else in the enum body can match, and the comment now records that reasoning. Verified with ten mutation cases, all of NVIDIA#803's seven plus three for this change: * a single-line tuple variant with no row is caught (`profile`); * a multi-line tuple variant is caught (`bisect`), so a reflowed field list does not reopen the hole; * a tuple variant carrying `hide = true` is still correctly excluded, which is the case a wider pattern could plausibly have broken. The original seven are unchanged: new unit/struct variant, deleted row, invented row, a row for the hidden command, a rename, and both parse self-tests. The widened parse still agrees with the built binary -- 15 visible subcommands, 15 table rows, no disagreement -- and `just check-guards` is green. Both inputs are bit-identical after the mutation run. Signed-off-by: Vyncint Ng <[email protected]>
Collaborator
|
Gist: the follow-up named in the #803 merge note. The variant regex now catches tuple, inline-struct, and trailing-comment forms instead of silently skipping them. Verified here:
Landing once CI is green. |
nihalpasham
approved these changes
Aug 12, 2026
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.
The follow-up you noted on #803 — "the variant regex skips tuple variants (none
exist today); extending it closes the one silent hole."
The hole
The pattern was:
It requires the line to end after an optional
{or,. A tuple variantcarries its fields on the same line —
Profile(String),— so it matched nothingand that subcommand was never required to appear in the book's table.
Silent, which is the bad direction for a guard: a missed variant does not fail,
it just quietly stops being checked.
The fix
The identifier may now be followed by
{,(,,or end of line, covering allthree variant shapes:
Widening is safe because the 4-space indent is what separates variants from
everything else in the block: doc comments start with
/, attributes with#, abody's closing brace with
}, and a variant's own fields are indented deeper. Sonothing else in the enum body can match. The comment now records that reasoning,
since it is the load-bearing assumption.
Verification — ten mutation cases
Three new ones for this change:
profile)bisect) — a reflowed field list does not reopen the holehide = trueAnd #803's original seven, all still caught with no regression: new unit/struct
variant, deleted row, invented row, a row for the hidden command, a rename, and
both parse self-tests.
Also re-ran the checks you verified independently on #803:
15 table rows, zero disagreement;
just check-guardsgreen end to end;git diffclean).One script, one regex, one comment. No behaviour change today, since the enum has
no tuple variants — this is the hole closing before something falls in it.