Null items: the semicolon after endgenerate, and everywhere else an item may stand
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]>
This commit is contained in:
1 parent
1e30ea0fb5
commit
307a56e921
15 files changed
+1522
-5
No files matched your search
@@ -1413,6 +1413,14 @@ impl<'a> Parser<'a> {
|
||||
if self.at_macro_item() || self.at_spaced_macro_call() {
|
||||
return Ok(ItemKind::MacroItem(self.parse_macro_call()?));
|
||||
}
|
||||
// A null item. Nothing else in the item grammar starts with `;`, so
|
||||
// one token settles it — and it is tested here rather than in the
|
||||
// `TokenKind` match below because punctuation is matched by text
|
||||
// everywhere in this file. See `ItemKind::Empty`.
|
||||
if self.cur().is_sym(";") {
|
||||
self.bump();
|
||||
return Ok(ItemKind::Empty);
|
||||
}
|
||||
let t = self.cur();
|
||||
match t.kind {
|
||||
TokenKind::Directive => {
|
||||
|
||||
Reference in new issue
Block a user