Fix round-1 QA findings: Inline width in fits(), action-block nesting, comment gaps
printer::fits() now measures from a multi-line Doc::Inline's last line and
keeps measuring the rest of the group (a with {...} block no longer hides
an overflow). skip_action_stmt tracks begin/end, fork/join, case/endcase
nesting so a concurrent assertion's action block is captured whole.
Comments between bind/target/module and around randomize(...) with are
attached and reprinted instead of being refused by the safety net.
All 800 passing corpus files format byte-identically before and after.
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
e35da292bd
commit
a4f8476894
14 files changed
+656
-57
No files matched your search
@@ -165,6 +165,10 @@ the same two grammar rules and cost nothing:
|
||||
workspace) all clean.
|
||||
- [x] Idempotency swept by hand over all 712 passing corpus files, not just
|
||||
the 13 new ones.
|
||||
- [x] QA round-1: `skip_action_stmt` tracks `begin`/`end`, `fork`/`join*` and
|
||||
`case`/`endcase` nesting, so an action block that is an `if` with a
|
||||
`begin ... end` body (with or without `else`) is captured whole
|
||||
(3 parser tests + 2 cases).
|
||||
- [ ] **Not done, deliberately:** canonical layout for property/sequence
|
||||
expressions; `expect property`; `cover sequence`; `default clocking` /
|
||||
`default disable iff` (interface cluster's).
|
||||
@@ -278,6 +282,56 @@ Files changed:
|
||||
- `README.md` — "Supported syntax" bullet, roadmap items 7/7b/8
|
||||
- `docs/features/assertions/README.md` — this file
|
||||
|
||||
### 2026-08-21 — dev (response to QA round 1)
|
||||
|
||||
The round-1 finding below — `skip_action_stmt`'s generic branch tracking
|
||||
brackets but not `begin`/`end`, so an action block like `if (c) begin x = 1;
|
||||
end else y = 2;` ended at the first `;` *inside* the nested block — is fixed.
|
||||
|
||||
`skip_action_stmt` is now one loop with a block-keyword depth counter beside
|
||||
the bracket skipping. It counts the openers `BLOCK_OPENERS` (`begin`, `fork`,
|
||||
`case`/`casex`/`casez`/`randcase`) against the closers `BLOCK_CLOSERS`
|
||||
(`end`, `join`/`join_any`/`join_none`, `endcase`), and:
|
||||
|
||||
- a `;` ends the statement only at depth 0, so a `;` inside a nested block no
|
||||
longer ends the scan;
|
||||
- a statement that *ends* with a block ends there — no `;` follows one — and
|
||||
the scan then reads the optional `end : label` and continues only if an
|
||||
`else` follows, which is what makes the `if`/`else` shape whole;
|
||||
- `disable fork` / `wait fork` are matched as a pair and skipped: they name
|
||||
the enclosing block rather than opening one, and counting them would have
|
||||
broken the very common UVM `fork ... join_none` + `disable fork` action
|
||||
block;
|
||||
- a closer at depth 0 (nothing open) is a clean `expected ';'` error where it
|
||||
stands, which is both a better position than the old run-to-EOF and the
|
||||
reason the counter can never underflow.
|
||||
|
||||
The termination argument the QA log asked about still holds and is now in the
|
||||
doc comment: `at_eof` is checked on every turn and every arm consumes at
|
||||
least one token, so unbalanced input is a clean parse error, never a loop and
|
||||
never a read past the end of the file. Both directions are pinned by
|
||||
`an_unbalanced_action_block_is_a_clean_error`.
|
||||
|
||||
Tests: three parser tests (`an_action_block_keeps_a_nested_begin_end_whole`,
|
||||
`an_action_block_may_be_a_fork_or_a_case`,
|
||||
`an_unbalanced_action_block_is_a_clean_error`) and two cases in
|
||||
`assertions.cases` (the `if`/`begin`/`end`/`else` shape and a
|
||||
`fork ... join_none` with `disable fork` inside), each with a following item
|
||||
asserted to survive so a future over-greedy scan is caught.
|
||||
|
||||
The old special case that required the pass statement's *first* token to be
|
||||
`begin` is gone — it is now just depth 1 on the first token — so the previous
|
||||
begin-block behaviour is unchanged, `begin`-first or not.
|
||||
|
||||
Score unchanged before and after
|
||||
(`{"passing":800,"total":820,"pct":97.6,...}`), passing set identical, all
|
||||
800 passing files byte-identical against the pre-change binary, two-pass
|
||||
idempotency sweep clean.
|
||||
|
||||
Files changed: `crates/vlog_parser/src/parser.rs` (`skip_action_stmt`, the
|
||||
two new consts, 3 tests), `crates/vlog_formatter/tests/cases/assertions.cases`
|
||||
(2 cases).
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-08-21 — round-1 adversarial QA
|
||||
|
||||
@@ -105,6 +105,11 @@ instantiation too (`bind.cases`, "implicit named *parameter* overrides").
|
||||
|
||||
### Promised / requested
|
||||
|
||||
- **`BindDirective::target_comments` / `::module_comments`** (QA round-1 fix):
|
||||
the comments written between `bind` and the target, and between the target
|
||||
(or the `: instance, list`) and the module name. Both are plain
|
||||
`Vec<Comment>` fields, so no consumer had to change; only `Fmt::bind`
|
||||
reads them.
|
||||
- **New AST variant `ItemKind::Bind(BindDirective)`** in
|
||||
`crates/vlog_parser/src/ast.rs`. Two exhaustive matches in other crates
|
||||
needed an arm; both got the minimal one:
|
||||
@@ -149,6 +154,11 @@ instantiation too (`bind.cases`, "implicit named *parameter* overrides").
|
||||
- [x] `cargo fmt --all`, `cargo clippy --all-targets`, `cargo test` all clean.
|
||||
- [x] Score after: 699/820 (85.2%), passing set a strict superset.
|
||||
- [x] `TODO.md` and `README.md` updated.
|
||||
- [x] QA round-1: comments between `bind` and the target, and before the
|
||||
module name, are preserved (2 cases + 1 parser test).
|
||||
- [ ] A comment written *inside* the `: instance, list` is still a clean
|
||||
exit-2 refusal — `instances: Vec<Name>` has no `Meta` and no corpus
|
||||
file writes one. See the 2026-08-21 work log entry.
|
||||
|
||||
## Work log
|
||||
|
||||
@@ -196,6 +206,47 @@ instantiation too (`bind.cases`, "implicit named *parameter* overrides").
|
||||
from `counter_properties.sv:96`), so nothing in this category is left over;
|
||||
those files belong to the `assertions` owner.
|
||||
|
||||
### 2026-08-21 — dev (response to QA round 1)
|
||||
|
||||
The round-1 finding below (a comment between `bind` and its target is dropped
|
||||
internally and the file becomes unformattable) is fixed, together with its
|
||||
sibling position (between the target — or the `: instance, list` — and the
|
||||
module name of the instantiation).
|
||||
|
||||
Both positions sit between two tokens that no node owns: the target is a bare
|
||||
`String`, so a comment written there had nowhere to attach and drifted onto
|
||||
the instance below, which moves it across tokens and `verify_equivalence`
|
||||
rightly refused the output. `BindDirective` now carries `target_comments` and
|
||||
`module_comments`, harvested in `parse_bind` with the same `take_dangling`
|
||||
the rest of the parser uses, and `Fmt::bind` prints each back where it was
|
||||
written (`Fmt::inline_comments_spaced`, so a *line* comment ends its line and
|
||||
the target starts the next one). Both round-trip and are idempotent; two
|
||||
cases in `bind.cases` pin them, plus a parser test
|
||||
(`the_comments_around_a_binds_head_are_kept`).
|
||||
|
||||
The QA note's "same class of gap ... after the module name / before the
|
||||
instance name" turned out **not** to reproduce: `checker_mod /*c3*/ c_inst
|
||||
/*c4*/ (.clk(clk));` already round-trips, because those two positions are the
|
||||
instance's `meta.leading` and `conn_comments`, which `parse_instantiation`
|
||||
has always harvested.
|
||||
|
||||
**Still refused, deliberately:** a comment written *inside* the `: instance,
|
||||
list` (`bind dut : /*x*/ u_a chk u (.*);`). `instances: Vec<Name>` has no
|
||||
`Meta`, and giving one to a list nothing else needs — no corpus file writes a
|
||||
comment there — is the abstraction-for-a-second-user-that-does-not-exist the
|
||||
project rules forbid. It stays a clean exit-2 refusal with the input
|
||||
untouched, not corruption.
|
||||
|
||||
Score unchanged before and after
|
||||
(`{"passing":800,"total":820,"pct":97.6,...}`), passing set identical, and
|
||||
all 800 passing corpus files format to byte-identical output against the
|
||||
pre-change binary; the two-pass idempotency sweep over them is clean.
|
||||
|
||||
Files changed: `crates/vlog_parser/src/ast.rs` (two fields on
|
||||
`BindDirective`), `crates/vlog_parser/src/parser.rs` (`parse_bind` + 1 test),
|
||||
`crates/vlog_formatter/src/format.rs` (`Fmt::bind`),
|
||||
`crates/vlog_formatter/tests/cases/bind.cases` (2 cases).
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-08-21 — round-1 adversarial QA
|
||||
|
||||
@@ -129,9 +129,21 @@ its input bytes exactly is trivially token-equivalent.
|
||||
- **`Doc::Inline(String)`** (`vlog_formatter::doc`): verbatim text spliced
|
||||
into the *middle* of a line, newlines and all. Unlike `Doc::Verbatim` it
|
||||
does not force enclosing groups to break, and unlike `Doc::Text` the
|
||||
printer measures it correctly (`fits` charges only its first line, `print`
|
||||
resumes measuring from its last). `align::flat_width` returns `None` for it,
|
||||
as it does for the other break-carrying docs.
|
||||
printer measures it correctly: `fits` charges its first line against the
|
||||
current width and then goes on measuring the rest of the group from the
|
||||
width of its *last* line, which is where `print` resumes (QA round-1 fix —
|
||||
the first version stopped measuring at the first line and let an
|
||||
overflowing tail through). `align::flat_width` returns `None` for it, as it
|
||||
does for the other break-carrying docs.
|
||||
|
||||
- **Comment slots on three `ExprKind` variants** (QA round-1 fix):
|
||||
`Call { comments: Box<CallComments> }` (before the `(`, and inside an empty
|
||||
`()`), `With`/`WithConstraint { comments: Box<WithComments> }` (before
|
||||
`with`, and between `with` and the `(` / `{`). Every consumer matched these
|
||||
variants with named fields; `vlog_semantic::bind` and
|
||||
`vlog_parser/tests/spans.rs` got a `..` in the pattern and nothing else.
|
||||
The comments live outside the nodes' code extents, so no span invariant
|
||||
changes.
|
||||
- **`token::is_keyword` gained `randcase` and `let`** — a lexer-level change
|
||||
shared with the `lexer-cleanup` feature. See Assumptions.
|
||||
|
||||
@@ -190,6 +202,13 @@ another feature's region, so they are written here rather than made:
|
||||
- [x] 30 formatter cases in `crates/vlog_formatter/tests/cases/dv_statements.cases`,
|
||||
14 parser unit tests, 1 linter case, 2 new span-invariant sources
|
||||
- [x] `cargo fmt` / `cargo clippy --all-targets` / `cargo test` clean
|
||||
- [x] QA round-1: `fits()` keeps measuring past a multi-line `Doc::Inline`,
|
||||
from its last line's width
|
||||
- [x] QA round-1: comments before a call's `(`, inside an empty `()`, and on
|
||||
either side of a postfix `with`
|
||||
- [ ] comment between an expression statement and its `;` — not a `with`
|
||||
gap (`y = a + 1 /*c*/;` refuses the same way); needs a slot on the
|
||||
statement, and is the shape TODO.md already parks
|
||||
- [ ] `let` at *statement* position (a block item declaration, §11.12) — no
|
||||
corpus file writes one; it is an "unsupported statement starting with
|
||||
keyword `let`" error
|
||||
@@ -296,6 +315,63 @@ Files changed:
|
||||
- `crates/vlog_linter/tests/cases/case_missing_default.lint` — randcase case
|
||||
- `README.md`, `TODO.md`
|
||||
|
||||
### 2026-08-21 — dev (response to QA round 1)
|
||||
|
||||
Two of the round-1 findings in the QA log below were this cluster's; both are
|
||||
fixed. Score unchanged at `{"passing":800,"total":820,"pct":97.6,...}` before
|
||||
and after, with the passing set identical (`comm` both ways empty) and — the
|
||||
stronger check for a printer change — **every one of the 800 files formats to
|
||||
exactly the same bytes as the pre-change binary** (built from `HEAD` in a
|
||||
scratch tree and diffed file by file). The 800-file two-pass idempotency
|
||||
sweep is clean.
|
||||
|
||||
- **`fits()` vs a multi-line `Doc::Inline` (printer.rs).** Confirmed exactly
|
||||
as reported: `fits` returned on the Inline's first line, so a group whose
|
||||
tail continued on the block's *last* line was judged to fit however long
|
||||
that tail was. `fits` now charges the first line, refuses the group if that
|
||||
line alone overflows, then **resets the remaining width to
|
||||
`max_width - <last line's width>` and keeps measuring** the rest of the
|
||||
group — which is precisely what `print` does when it resumes. The QA repro
|
||||
now wraps at `--line-length 40`, and the control case (a short tail after
|
||||
the same block) still comes out flat. Two printer unit tests pin both
|
||||
directions (`group_stays_flat_when_the_tail_after_an_inline_fits`,
|
||||
`group_breaks_when_the_tail_after_an_inline_overflows`) and two
|
||||
`dv_statements.cases` entries pin it end to end at the default 100 columns
|
||||
(`cases.rs` has no per-case config knob — every case runs on
|
||||
`Config::default()` — so the cases are built to overflow at 100).
|
||||
- **`align::flat_width` was checked and deliberately left alone.** It answers
|
||||
`None` for *any* `Doc::Inline`, which makes the row unalignable; `row_of`
|
||||
turns that into `None`, and `align_groups` treats a `None` row as a group
|
||||
boundary whose plan stays `None`, so the row prints flush. That is
|
||||
conservative but correct in the direction that matters (no row is ever
|
||||
padded from a width nobody measured). The only pessimism is a *single-line*
|
||||
Inline, which does have an honest flat width; no corpus file writes one
|
||||
inside an alignable row, so under "simplicity first" it stays as it is
|
||||
rather than growing a special case with no user.
|
||||
- **Comments at the `randomize()`/`with` boundaries.** Four positions had no
|
||||
node to attach to and so were rejected by the safety net: before a call's
|
||||
`(`, inside an empty `()`, before `with`, and between `with` and the `(` /
|
||||
`{`. `ExprKind::Call` gained `comments: Box<CallComments>` and both `with`
|
||||
forms gained `comments: Box<WithComments>` — boxed for the reason
|
||||
`TernaryComments` already gives — harvested with the existing
|
||||
`take_before_open` / `take_dangling` helpers and printed back between the
|
||||
same two tokens by `Fmt::with_head` and the `Call` arm. An argument list
|
||||
with elements keeps carrying its own comments (a second home would print
|
||||
one comment twice); a parser test pins that too.
|
||||
- **Still refused, deliberately:** a comment between an expression statement
|
||||
and its `;` (`y = x.randomize() with {a == 1;} /*c*/;`). It is not a
|
||||
`with`-specific gap at all — `y = a + 1 /*c*/;` refuses identically — and
|
||||
placing it needs a slot on the *statement*, not on `Expr`. It is the shape
|
||||
TODO.md already parks as "a comment before a procedural statement's `;`".
|
||||
|
||||
Files changed: `crates/vlog_formatter/src/printer.rs` (the `fits` arm + 2
|
||||
tests), `crates/vlog_parser/src/ast.rs` (`CallComments`, `WithComments`, the
|
||||
three new fields), `crates/vlog_parser/src/parser.rs` (harvest points,
|
||||
`parse_with_constraint` no longer eats its own `with`, 2 tests),
|
||||
`crates/vlog_formatter/src/format.rs` (`with_head`, the `Call` arm),
|
||||
`crates/vlog_semantic/src/bind.rs` + `crates/vlog_parser/tests/spans.rs`
|
||||
(`..` in the three patterns), `tests/cases/dv_statements.cases` (3 cases).
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-08-21 — round-1 adversarial QA
|
||||
|
||||
Reference in new issue
Block a user