Owner report: 'for loop inside generate shows expected item (found ;) at endgenerate;'. Lead diagnosis before dispatch: every generate-for spelling and three systemverilog.io examples already parsed; the failing token was the lone ';' - IEEE 1800-2017 A.1.4's null item, legal in module, generate, package, interface, program and class scope and at file scope, rejected by lucisv in all of them. ItemKind::Empty, one branch at the top of parse_item_kind, the three exhaustive arms topo 3.3 predicts and no others. The formatter keeps the ';' where it was written - glued to the previous sibling's line (endgenerate; end; endmodule; ;;) when no newline separates them and the ';' carries no docs of its own, else on a line of its own - decided from src spans in item_seq rather than a parser flag. verify.rs untouched, eight attack pairs. New empty-item lint (slang's -Wempty-member) with a safe fix whose deletion range structurally cannot swallow a comment. Corpus byte-identical at 813/820 against the pre-change binary; opentitan sweep identical file-for-file; empty-item fires zero times there. The LSP now publishes a warning with a quick fix where it used to publish a parse error. docs/features/null-items/README.md; TODO.md section 14. Co-Authored-By: Claude Fable 5 <[email protected]>
453 lines
26 KiB
Markdown
453 lines
26 KiB
Markdown
# null-items
|
|
|
|
## Goal
|
|
|
|
Accept the **null item** — a lone `;` written where a module, generate,
|
|
package, interface, program or class item belongs, and at file scope. It is
|
|
legal SystemVerilog (IEEE 1800-2017 A.1.4:
|
|
`package_or_generate_item_declaration ::= … | ;`, `class_item ::= … | ;`, and
|
|
`description → package_item` reaches it at file scope), it means nothing, and
|
|
people write it all the time — after `endgenerate`, after a generate block's
|
|
`end`, after `endmodule`. lucisv rejected every one of those with
|
|
`parse error: expected item (found ";")`, which is what the owner hit when
|
|
they wrote `endgenerate;` after a perfectly good generate-`for` loop. (The
|
|
generate-`for` itself was never the problem: every spelling of it already
|
|
parsed and round-tripped, and this feature pins three real-world examples to
|
|
keep it that way.)
|
|
|
|
Three things ship together: `ItemKind::Empty` in the parser, a
|
|
token-preserving layout rule in the formatter (a `;` written on the same line
|
|
as the item before it stays on that line), and a default-on lint,
|
|
`empty-item`, whose safe fix deletes the `;` — the equivalent of slang's
|
|
`-Wempty-member` ("an unnecessary semicolon is located in a non-procedural
|
|
scope (such as a module body)"). The procedural sibling — the null
|
|
*statement*, `initial begin ; end` — already worked and is untouched, as is
|
|
`endfunction;`/`endtask;`, which the `end_semi` flag on `FunctionDecl` /
|
|
`TaskDecl` has recorded since the classes round (`parser.rs`,
|
|
`parse_function_decl`: "the stray `;` is a null class item"). That flag is the
|
|
precedent this work generalizes; it is deliberately left alone, so the two
|
|
mechanisms do not overlap.
|
|
|
|
## Assumptions
|
|
|
|
- **A `;` at item position is always a null item.** Nothing else in the item
|
|
grammar can start with `;`, so the one-token test in `parse_item_kind` is
|
|
unambiguous. Before this change the token was a hard error there, so no
|
|
previously-parsing source changes meaning.
|
|
- **`endfunction;` / `endtask;` keep going through `end_semi`.** The parser
|
|
consumes that `;` inside `parse_function_decl`/`parse_task_decl` before the
|
|
item loop ever sees it, so it never becomes an `ItemKind::Empty`. Two
|
|
spellings of the same source fact would be worse than one; the existing one
|
|
already prints back where it was written.
|
|
- **"Same line" is a question about the previous *sibling item*, not the
|
|
previous token.** See Handshakes for the argument; the consequence is that a
|
|
null item that is the *first* item of a body always prints on its own line
|
|
(`module m;` ⏎ ` ;` ⏎ `endmodule`, `generate` ⏎ ` ;` ⏎ `endgenerate`),
|
|
because there is no sibling to glue to.
|
|
- **A `//` comment can never stand between the previous item and a glued
|
|
`;`.** It would swallow the `;` to end of line, so the only comment that
|
|
fits in a newline-free gap is a single-line block comment, which prints
|
|
inline and keeps the `;` after it. This is what makes gluing safe: the
|
|
formatter can never append `;` after a line comment.
|
|
- **A null item declares nothing and references nothing**, so
|
|
`vlog_semantic`'s `bind.rs` treats it as a leaf, and `vlog_linter`'s
|
|
catch-all `visit.rs` walk needs no arm.
|
|
- **The 820-file corpus contains no null item**, so its output must stay
|
|
byte-identical. Any drift there is a bug in this feature, not a style
|
|
change.
|
|
|
|
## Handshakes
|
|
|
|
### Consumed
|
|
|
|
- `vlog_parser::ast::Item`/`Meta` — the null item's comments ride the ordinary
|
|
`Meta` (leading, trailing), exactly like any other item; its `span` is the
|
|
`;` token alone.
|
|
- `vlog_formatter`'s `Fmt::src` and item spans — the same way `align.rs` and
|
|
`format.rs`'s `eq_offset` / `open_paren_offset` / `default_has_colon`
|
|
already ask the source a layout question the AST does not answer.
|
|
- `vlog_linter`'s `registry::Rule`, `visit::walk_items`, `Fix::safe` and the
|
|
`.lint` harness's `----` fix section.
|
|
|
|
### Promised (exhaustive-match arms this variant costs)
|
|
|
|
Per `docs/topo.md` §3.3, a new `ItemKind` variant costs an arm everywhere the
|
|
match is exhaustive. Added by this lane:
|
|
|
|
| file | arm |
|
|
|---|---|
|
|
| `crates/vlog_parser/src/ast.rs` | the variant itself, `ItemKind::Empty` |
|
|
| `crates/vlog_parser/src/parser.rs` | `parse_item_kind`'s `;` branch |
|
|
| `crates/vlog_parser/tests/spans.rs` | `ItemKind::Empty => {}` (a leaf; the item's own span is checked by the caller) |
|
|
| `crates/vlog_formatter/src/format.rs` | `item_kind`'s `ItemKind::Empty => text(";")`, plus the `item_seq` glue rule |
|
|
| `crates/vlog_semantic/src/bind.rs` | folded into the leaf group `\| ItemKind::Verbatim(_) => {}` |
|
|
|
|
Catch-all matches that needed nothing, confirmed by compiling: `vlog_linter`'s
|
|
`visit.rs` / `signals.rs`, `vlog_formatter`'s `fence.rs` / `range.rs` /
|
|
`verify.rs`, `vlog_refactor`'s `ports.rs` / `instantiate.rs`, `vlog_semantic`'s
|
|
`instantiations.rs` / `classes.rs`, and the server's `completion.rs`,
|
|
`type_def.rs`, `linked.rs`, `selection.rs`, `symbols.rs`, `tokens.rs`,
|
|
`on_type.rs`, `type_hierarchy.rs`.
|
|
|
|
### The glued/own-line decision, and where "same line" is decided
|
|
|
|
**Decided in the formatter, from `src` spans; no parser flag.** `item_seq` is
|
|
the one place that emits the separator between two sibling items, and the
|
|
question the glue asks is exactly the one it is already answering ("what goes
|
|
between item *n-1* and item *n*"). A parser-recorded flag would answer a
|
|
*different* question — "was there a newline since the previous **token**" —
|
|
which differs precisely where it matters least and hurts most: for the first
|
|
item of a body the previous token is the opener (`generate`, the header `;`,
|
|
`begin`), and gluing there would mean reaching back into a construct's
|
|
header layout from its body's item list. It would also put a formatter-only
|
|
layout fact into the AST that every other consumer must ignore. The source
|
|
check is one `contains('\n')` over the gap between the previous item's
|
|
`span.end` and the `;`'s `span.start`, which is the established idiom in this
|
|
file.
|
|
|
|
The rule, then:
|
|
|
|
- a null item whose `;` has **no newline** between it and the previous
|
|
sibling item prints **glued** to that item's last line: `endgenerate;`,
|
|
`end;`, `;;`, `endmodule;`;
|
|
- **otherwise** — a newline in the gap, no previous sibling, a leading
|
|
comment, an attribute, or a format-off fence opening on it — it prints `;`
|
|
on its own line at the current indent.
|
|
|
|
Both are fixed points: re-parsing glued output finds no newline in the gap and
|
|
glues again; re-parsing own-line output finds one and does not. Both
|
|
directions are pinned in `tests/cases/null_items.cases`.
|
|
|
|
Alignment: `param_decl_row` returns `None` for any non-`ParamDecl` item and
|
|
`align_groups` breaks a run at a `None` row, so a null item between two
|
|
`parameter` declarations splits the alignment group with no new code. Pinned
|
|
by a case.
|
|
|
|
### Filed (nothing)
|
|
|
|
No cross-module request; nothing is owed by another module. Every file this
|
|
lane touched:
|
|
|
|
| file | change |
|
|
|---|---|
|
|
| `crates/vlog_parser/src/ast.rs` | `ItemKind::Empty` |
|
|
| `crates/vlog_parser/src/parser.rs` | the `;` branch in `parse_item_kind` |
|
|
| `crates/vlog_parser/tests/spans.rs` | the leaf arm |
|
|
| `crates/vlog_parser/tests/null_items.rs` | **new** — the per-scope parser tests the brief asked for |
|
|
| `crates/vlog_formatter/src/format.rs` | `item_kind` arm, `item_seq` glue, `glued_null_item` |
|
|
| `crates/vlog_formatter/tests/cases/null_items.cases` | **new** — 22 layout/idempotency cases |
|
|
| `crates/vlog_formatter/tests/verification.rs` | three masked-corruption pairs |
|
|
| `crates/vlog_semantic/src/bind.rs` | the leaf arm |
|
|
| `crates/vlog_linter/src/rules/empty_item.rs` | **new** — the rule |
|
|
| `crates/vlog_linter/src/rules/mod.rs` | `pub mod empty_item;` |
|
|
| `crates/vlog_linter/src/registry.rs` | one line in `all_rules()` |
|
|
| `crates/vlog_linter/tests/cases/empty_item.lint` | **new** — 20 lint/fix cases |
|
|
| `docs/features/null-items/README.md` | **new** — this document |
|
|
| `TODO.md` | §14 ticked |
|
|
|
|
`vlog_formatter/src/align.rs` was **not** touched: the group split falls out
|
|
of `param_decl_row` returning `None`, so the rule the brief allowed for was
|
|
not needed. `verify.rs` was not touched either (invariant 4). Two files are
|
|
outside the brief's literal list and are recorded here rather than assumed:
|
|
`vlog_parser/tests/null_items.rs` (the brief asked for parser unit tests but
|
|
named no file) and `vlog_linter/src/rules/mod.rs` (a new rule module cannot
|
|
be registered without it).
|
|
|
|
## Status / TODO
|
|
|
|
- [x] `ItemKind::Empty` — a leaf variant, span = the `;`, comments through
|
|
`Meta`.
|
|
- [x] `parse_item_kind` accepts `;`; every item list reaches it (they all go
|
|
through `item_or_recover` → `parse_item`).
|
|
- [x] Tolerant mode emits no diagnostic for it (it is a successful parse, not
|
|
a recovery).
|
|
- [x] Formatter: glued / own-line layout, idempotent both ways.
|
|
- [x] Alignment groups are not joined across a null item.
|
|
- [x] Blast-radius arms (`format.rs`, `bind.rs`, `spans.rs`).
|
|
- [x] `verify.rs` untouched; three rejection pairs added to
|
|
`tests/verification.rs` anyway.
|
|
- [x] Lint `empty-item`, default on, safe fix, `.lint` case with fix output.
|
|
- [x] `tests/cases/null_items.cases` — the owner's shape, every reproduction,
|
|
slang's two examples, three systemverilog.io generate examples.
|
|
- [x] Parser unit tests per scope.
|
|
- [x] `TODO.md` §14 ticked.
|
|
|
|
## Work log
|
|
|
|
### 2026-09-01 — dev
|
|
|
|
Reproduced the lead's list against the tree at `1e30ea0` first: `b.sv`
|
|
(`endgenerate;`), `e.sv` (lone `;` at module scope), `f1` (`generate ;
|
|
endgenerate`), `f2` (`end;` inside a region), `f3`/`f4`/`f5`
|
|
(package/interface/class), `f7` (`endmodule;`), `f9` (region-less `end;` and
|
|
`;;`) all failed with `expected item (found ";")`; `a`/`c`/`d` (three
|
|
generate-`for` spellings), `f8` (procedural null statement) and `f6`
|
|
(`endfunction;`/`endtask;`) already passed. Same verdicts the lead reported.
|
|
|
|
**Parser.** `ItemKind::Empty` added to `ast.rs` as a unit variant directly
|
|
before `Error`, and one branch at the top of `parse_item_kind`:
|
|
|
|
```rust
|
|
if self.cur().is_sym(";") {
|
|
self.bump();
|
|
return Ok(ItemKind::Empty);
|
|
}
|
|
```
|
|
|
|
Every item list in the parser — file, module/interface/program body, package
|
|
body, class body, `generate` region, `parse_gen_block`'s begin/end body and
|
|
its single-item body — goes through `item_or_recover` → `parse_item` →
|
|
`parse_item_kind`, so one branch covers all eight scopes. Verified by test
|
|
rather than by reading, per the brief: `tests/null_items.rs` parses one case
|
|
per scope strictly and asserts an `Empty` item with `src[span] == ";"`.
|
|
|
|
The branch sits *before* the `TokenKind` match, not inside it, because the
|
|
lexer's symbol tokens are matched by text (`is_sym`), not by a `TokenKind`
|
|
variant per symbol; that is how the rest of the file tests for punctuation.
|
|
|
|
**Formatter.** `item_kind` gets `ItemKind::Empty => text(";")`. The layout
|
|
lives in `item_seq`, which now tracks the previous item that actually emitted
|
|
docs and suppresses the separator when `glued_null_item` says so. The
|
|
predicate refuses to glue when the null item has a leading comment, an
|
|
attribute, a blank line before it, or a fence opening on it — each of those
|
|
gives the `;` docs of its own that must not be appended to the previous
|
|
line — and finally asks the source whether the gap holds a newline.
|
|
|
|
**Blast radius.** `cargo check --workspace` named exactly three other
|
|
exhaustive matches: `format.rs` (the arm above), `bind.rs` (folded into the
|
|
existing leaf group), `spans.rs` (`Empty => {}`). Nothing else in the eight
|
|
crates or the server needed a line, which the Handshakes table records.
|
|
|
|
**Safety net.** `verify.rs` untouched, per CLAUDE.md invariant 4. Three
|
|
masked-corruption pairs added to `tests/verification.rs`: an output that drops
|
|
the `;`, one that moves it to the other side of a comment, and one that moves
|
|
an item-level `;` into an adjacent procedural block. All three are rejected by
|
|
the net as it stands, which is the point of writing them down.
|
|
|
|
**Lint.** `empty-item`, default on, safe fix, listed between
|
|
`case-missing-default` and `enum-name-style` (the registry is asserted
|
|
alphabetical). The fix deletes the `;` plus the horizontal whitespace before
|
|
it, and takes the newline too when what stood on that line was nothing but
|
|
whitespace and other null items — so `;;;` on a line leaves no blank line
|
|
behind, while `endgenerate; // note` becomes `endgenerate // note` with the
|
|
comment untouched and `; // why` leaves the comment on its line. A final
|
|
guard refuses to emit a fix whose range covers anything but `;` and
|
|
whitespace: the range is built so that it cannot, and the check makes
|
|
"comments are never dropped" true by construction rather than by argument.
|
|
Both shapes are in `tests/cases/empty_item.lint`, whose harness re-lints to a
|
|
fixpoint and re-formats the fixed text.
|
|
|
|
**Cases.** `tests/cases/null_items.cases`: 22 cases — the owner's shape, each
|
|
reproduction from the lead's list, slang's `-Wempty-member` / `-Wempty-stmt`
|
|
examples, the glued/own-line idempotency pair in both directions, the
|
|
comment shapes, the alignment-group split, and the three systemverilog.io
|
|
generate examples verbatim (16-input mux, `assert property` inside a
|
|
generate-`for`, the memory `case` with a nested `for` and hierarchical
|
|
instantiations) so a regression in generate-`for` is caught here too. The
|
|
harness re-formats every expected output, so each case is an idempotency
|
|
assertion as well as a layout one.
|
|
|
|
Parser coverage lives in `crates/vlog_parser/tests/null_items.rs`: one source
|
|
per scope, asserting `src[span] == ";"`; the `;;;` split; the comment
|
|
attachment; tolerant mode's silence; and that `endfunction;`/`endtask;` still
|
|
produce no null item.
|
|
|
|
**Gates.** `cargo fmt --all -- --check` clean; `cargo clippy --all-targets
|
|
--workspace` zero warnings; `cargo test --workspace` 2709 passed / 0 failed
|
|
(1 formatter case-table run covering 22 new cases, 1 lint case-table run
|
|
covering 21 new ones, 6 new parser tests, 3 new verification tests);
|
|
`scripts/corpus_gate.sh corpus` → `{"passing":813,"total":820,"pct":99.1}`,
|
|
exit 0, zero verification errors and zero crashes — the baseline unchanged.
|
|
Byte-identity was measured directly rather than inferred: a worktree at
|
|
`1e30ea0` was built and both binaries were run over all 820 corpus files —
|
|
**813 identical, 0 differing, 7 refused by both** (release and debug builds
|
|
agree). `cargo build -p lucisv_server` + `node editors/vscode/smoke.js
|
|
target/debug/lucisv-server` → OK, 20 messages.
|
|
|
|
Hand checks beyond the suites, each re-formatted to confirm a fixed point: a
|
|
null item after a `` `define`` and inside both arms of an `` `ifdef``; `` `endif; ``;
|
|
a CRLF file; an attributed `(* keep *) ;`; and `--lines` range runs that touch
|
|
the null item, the item before it and neither.
|
|
|
|
## QA log
|
|
|
|
### 2026-09-01 — QA
|
|
|
|
**Verdict: SHIP.**
|
|
|
|
**Gates.** `cargo fmt --all -- --check` clean. `cargo clippy --all-targets
|
|
--workspace` zero warnings. `cargo test --workspace`: 2709 passed / 0 failed
|
|
before my addition, matching the dev's number exactly (summed every `test
|
|
result:` line by hand); 2710 / 0 after adding one more verification test
|
|
(below). `scripts/corpus_gate.sh corpus` →
|
|
`{"passing":813,"total":820,"pct":99.1,...}` with all four failure categories
|
|
at their pre-existing counts, 0 verification errors, 0 crashes. `cargo build
|
|
-p lucisv_server` + `node editors/vscode/smoke.js target/debug/lucisv-server`
|
|
→ OK, 20 messages.
|
|
|
|
**Scope.** `git status --porcelain` / `git diff --stat` match the README's
|
|
file list exactly, with one addition the dev's list did not carry:
|
|
`docs/topo.md` (a `null-items` row added to §2.1 and §2.4, plus the doc-count
|
|
line and the `vlog_parser` feature-list row bumped) — reasonable and
|
|
consistent with how every other single-lane feature in this repo's history
|
|
self-registers in topo.md; not flagged as scope creep. `verify.rs` confirmed
|
|
absent from the diff (`git diff --name-only | grep verify.rs` → nothing).
|
|
No `unwrap()`/`expect()`/`panic!` introduced in library code — the two
|
|
`format.rs` matches (declarators, guarded by `items.len() == 1`) and every
|
|
`parser.rs`/`registry.rs` match are pre-existing and sit inside `#[cfg(test)]`
|
|
modules, confirmed by diff (this feature's parser.rs diff is exactly the
|
|
6-line `;`-branch add; nothing near those test lines).
|
|
|
|
**Doc finding (fixed directly, low severity).** The Filed table
|
|
(README:144, and the identical claim in `TODO.md`'s round-up) said
|
|
`empty_item.lint` holds "21 lint/fix cases"; counting `====`-delimited blocks
|
|
and `# ` case-name headers gives **20** (7 carry a `----` fix section, not
|
|
8). Miscount only — the harness (`lint_case_tables`) counts the same file the
|
|
same way and every case passes; nothing about the shipped behavior changes.
|
|
Fixed the README's line to 20; left `TODO.md`'s narrative prose alone since
|
|
it does not state a count. `null_items.cases`' claimed 22 is exact (`grep -c
|
|
'^# '` → 22).
|
|
|
|
**Parser + formatter attack (scratch `cargo run --example`, reverted after —
|
|
nothing here needed pinning beyond what the dev already has).** Every scope
|
|
in the checklist: first/last item of a module body, between two `assign`s in
|
|
an alignment group (splits correctly, columns differ across the split —
|
|
confirmed against the case at README-adjacent `null_items.cases:186`),
|
|
immediately after `(* attr *)`, both arms of `` `ifdef ``/`` `else ``/``
|
|
`endif ``, a `;` directly after `` `endif ``, after the `generate` keyword,
|
|
after `endgenerate`, `end;` after generate-`for`/generate-`if`/named
|
|
(`end : g;`) blocks, `;;;`, class/package/interface(with modport)/program
|
|
bodies, file scope between `endmodule` and `module`. All parsed, formatted,
|
|
and idempotent (`format(format(x)) == format(x)` checked directly, not just
|
|
via the case harness). Comment shapes — trailing line comment glued
|
|
(`endgenerate; // note`), trailing block comment glued, a block comment
|
|
alone on the null item's line, a line comment separating `endgenerate` from
|
|
a next-line `;` (stays own-line, correctly not glued across it), a leading
|
|
comment with a blank line above (blank preserved) — all round-tripped
|
|
correctly. CRLF file with `endgenerate;\r\n` formats and converges (CRLF→LF
|
|
is pre-existing general formatter behavior, not particular to this feature).
|
|
|
|
**One interaction checked and found pre-existing, not a regression.** A
|
|
`;` on its own line immediately after `endfunction` (e.g. inside a class,
|
|
between two methods) never becomes an `ItemKind::Empty`: `parse_function_decl`'s
|
|
`end_semi = self.eat_sym(";")` (parser.rs, untouched by this diff) is
|
|
whitespace/newline-blind — it eats the very next token regardless of an
|
|
intervening newline — so that `;` is absorbed into `FunctionDecl::end_semi`
|
|
and reprinted glued onto `endfunction`'s line, changing layout (not content)
|
|
on the first pass. Verified byte-for-byte identical on a worktree built from
|
|
`1e30ea0` (pre-feature) with the same input: this is standing `end_semi`
|
|
behavior this feature explicitly declines to touch (Assumptions), not
|
|
something introduced here. No action taken.
|
|
|
|
**Safety net (verify.rs).** Read all three new tests (7 pairs): dropped `;`
|
|
in two directions plus an invented one, a null item moved across a one-line
|
|
block comment (both directions: comment-then-semicolon vs
|
|
semicolon-then-comment, and a leading full-line comment swapped past the
|
|
`;`), and a null item's `;` swapped between an item slot and a procedural
|
|
statement slot. Ran `cargo test -p vlog_formatter --test verification
|
|
null_item` — all 3 tests / 7 pairs pass (i.e. `verify_equivalence` correctly
|
|
returns `Err` for every one). Read `verify.rs` in full: it is a strict
|
|
positional token-stream comparison (whitespace-blind, with only multi-line
|
|
directive/attribute/comment text trimmed per-line and the `@(*)`
|
|
canonicalization) — nothing in it forgives a token reorder, so every pair
|
|
above was expected to be rejected by construction, not by luck.
|
|
|
|
Added the checklist's suggested gap test — a null item carried from one
|
|
`` `ifdef `` arm to the other — as
|
|
`a_null_item_moved_from_one_ifdef_arm_to_the_other_is_rejected` in
|
|
`crates/vlog_formatter/tests/verification.rs` (kept; it is a real
|
|
regression pin, distinct from the existing pairs since the item list is
|
|
flat across `Directive` items and a directive-adjacent reorder was the one
|
|
shape not yet attacked). Confirmed rejected; noted in the test's own comment
|
|
that this was expected to hold given `verify.rs`'s positional design, so
|
|
this is a pinned confirmation, not a bug find.
|
|
|
|
**LSP smoke (checklist item 3, tolerant mode + diagnostics + code action).**
|
|
`crates/vlog_parser/tests/null_items.rs::tolerant_parsing_reports_no_diagnostic`
|
|
covers the parser side. For the editor-visible side, drove
|
|
`target/debug/lucisv-server` headlessly over stdio (hand-rolled framing
|
|
copied from `editors/vscode/smoke.js`'s pattern, run from the scratchpad, not
|
|
added to the tree): opened a buffer containing `endgenerate;`, requested
|
|
`textDocument/codeAction` over the `;`. Result: `publishDiagnostics` carries
|
|
no parse-error (severity-1) diagnostic, only an `empty-item` warning
|
|
(severity 2, code `empty-item`, message "unnecessary `;`; a null item does
|
|
nothing"); the code action response offers both the single-finding quick fix
|
|
(`lucisv: drop a `;` that stands where an item belongs [empty-item]`,
|
|
`isPreferred: true`) and `source.fixAll.lucisv`, both producing the correct
|
|
edit. Exactly the "warning, not a parse error, with a working fix" contract
|
|
the checklist asks for.
|
|
|
|
**Opentitan sweep (read-only throughout).** `git -C
|
|
/Users/guoliangchen/repo/opentitan status --porcelain` before and after:
|
|
unchanged, exactly the three expected pre-existing owner-modified files
|
|
(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
|
|
`hw/top_earlgrey/ip/ast/rtl/ast.sv`). Swept all 3,943 real `.sv`/`.svh` files
|
|
(32 symlinks excluded, same file count the clocking-wave baseline used) with
|
|
this feature's release `lucisv --no-cache --check`: **12** files exit
|
|
outside {0,1}, not 11 — but the 12th is
|
|
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, one of the three files with a local
|
|
uncommitted owner edit (`parse error: 749:1: expected declaration or
|
|
instantiation (found "as")`, clearly mid-edit). Built a second release
|
|
binary from a `git stash` of this feature's diff (i.e. trunk `1e30ea0`) and
|
|
swept the identical file list: **same 12 files, byte-identical set** (`diff`
|
|
of the two sorted failing-file lists is empty). So the standing 11-failure
|
|
grammar baseline is unchanged, and the 12th is the owner's own local WIP on
|
|
a file already flagged as "leave alone" — not a lucisv regression in either
|
|
direction, and not something this feature's parser change touches (it is a
|
|
`typedef`/enum-ish token error, nothing to do with a null item). Restored
|
|
this feature's worktree state (`git stash pop`) and rebuilt before
|
|
continuing; `git status --porcelain` on the lucisv tree also confirmed clean
|
|
of scratch artifacts (temporary `cargo run --example` files removed after
|
|
use). Lint sweep: `lucisv check --no-cache` over all 3,943 files, `grep -c
|
|
empty-item` → **0** — opentitan has no null items, matching the feature's
|
|
own stated assumption.
|
|
|
|
**Overall:** every gate green, scope matches modulo the topo.md
|
|
self-registration (normal), one doc miscount fixed, one interaction traced
|
|
to pre-existing `end_semi` behavior and confirmed not a regression, the
|
|
safety net's 7 pairs plus 1 QA-added pair all correctly rejected, the LSP
|
|
contract (warning + working fix, no false parse error) verified live, and
|
|
the opentitan sweep confirmed byte-identical to trunk. No blocking findings.
|
|
|
|
## Review
|
|
|
|
*(reserved for the lead)*
|
|
|
|
**2026-09-01 — lead.** Approved and committed.
|
|
|
|
- The owner's report was "for loop inside generate"; the lead's diagnosis
|
|
before dispatch was that every generate-for spelling — and the three
|
|
systemverilog.io examples — already parsed, and that the failing token was
|
|
the null item after `endgenerate`. The dev built exactly that, and the
|
|
case file pins both halves: the online examples (so a generate-for
|
|
regression is caught here too) and every null-item scope.
|
|
- Read the load-bearing code in full. The parser branch is one line at the
|
|
top of `parse_item_kind`. `glued_null_item` refuses any `;` that carries
|
|
docs of its own (leading comment, attribute, blank line, fence), so the
|
|
glue only ever appends a bare `;` — and deciding it from `src` spans in
|
|
`item_seq` rather than a parser flag is the right call: it is a layout
|
|
fact about the gap between siblings, asked where that gap is laid out,
|
|
the same idiom `eq_offset` and `default_has_colon` use. The lint's
|
|
`deletion` range ends in a guard that admits only `;`/whitespace bytes,
|
|
which makes swallowing a same-line comment structurally impossible
|
|
(invariant 3), and `;;` yields two adjacent non-overlapping fixes.
|
|
- Exhaustive-arm cost was exactly the three §3.3 predicts (`format.rs`,
|
|
`bind.rs`, `tests/spans.rs`); every other walker is catch-all. `verify.rs`
|
|
untouched, seven attack pairs from the dev plus QA's eighth (a `;` moved
|
|
between `` `ifdef `` arms), all rejected.
|
|
- Corpus byte-identical at 813/820, measured by the dev against a
|
|
pre-change worktree and re-run by QA. Opentitan sweep identical to trunk
|
|
file-for-file (the twelfth "failure" is the owner's in-progress `ast.sv`
|
|
edit, present before the round); `empty-item` fires zero times there,
|
|
confirming the tree has no null items and nothing moved.
|
|
- QA's informational note stands as designed: an own-line `;` right after
|
|
`endfunction`/`endtask` is still absorbed by the older `end_semi`
|
|
mechanism rather than becoming `ItemKind::Empty`; behavior is unchanged
|
|
from trunk and the lint deliberately does not report it. Worth a future
|
|
tidy (fold `end_semi` into the null item) but not this round's.
|
|
- Gates re-run by the lead before commit: fmt clean, clippy zero warnings,
|
|
full suite green (2 710), corpus gate 813/820, smoke OK. `docs/topo.md`
|
|
gains a grammar-lane row and a linter-lane row. Ships as 0.21.0 —
|
|
formatter output changes for files that contain a null item, so the
|
|
version bump is owed by the format-cache rule as well.
|