WIP checkpoint, §32 paused 2026-09-03 — runaway root cause fixed (list_ends on an unmoved cursor), strict parity restored; 32.1–32.5 done, 32.6 half, 32.7 + gates not run
Root cause of the 100 GB crash: a non-ANSI port loop took its trailing
comma from the element, an error element never got that far, the next
iteration failed on the same comma, consumed nothing and pushed another
empty error element - an allocating spin. Fix is structural: list_ends
ends the list whenever the cursor has not moved since the iteration
began; the two loops that read their own separator also eat it after an
error element. Truncate-anywhere + delete-any-character pass under
tools/guard.sh -m 4. Strict parity: element_or_recover declines on a
conditional-compilation directive so split.rs's verbatim rescue still
runs. cargo test -p vlog_parser 365 + 26 + 31 / 0 failed; workspace
suite NOT re-run since the last fixes. Not done: completion pin + the
three validity probes (32.6), measurements (32.7), README amendments,
coverage_gaps M10, TODO ticks, every gate. Handshake: three
vlog_linter arms (visit.rs walk_param_ports, signals.rs connection
loops) live in the earlier commit 6a15594.
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
6a15594ae8
commit
f1d44a2a0c
12 files changed
+639
-82
No files matched your search
@@ -32,6 +32,7 @@ impl<'a> Parser<'a> {
|
||||
imports.push(HeaderImport { meta, paths });
|
||||
}
|
||||
let param_comments = self.take_before_open("#");
|
||||
let mark = self.diags_mark();
|
||||
let ParamPortList {
|
||||
ports: param_ports,
|
||||
directives: param_directives,
|
||||
@@ -41,12 +42,10 @@ impl<'a> Parser<'a> {
|
||||
let port_comments = self.take_before_open("(");
|
||||
let (ports, port_dangling, port_directives) = self.parse_port_list()?;
|
||||
let before_semi = self.gap_before(";");
|
||||
// A header that already recovered keeps its `;` optional: the missing
|
||||
// one is part of the typo already reported, and the body behind it is
|
||||
// what the module is for.
|
||||
let recovered =
|
||||
param_ports.iter().flatten().any(|p| p.is_error()) || ports.has_error();
|
||||
self.expect_after_recovery(";", recovered)?;
|
||||
// A header that already reported something keeps its `;` optional: the
|
||||
// missing one is part of the typo already reported, and the body
|
||||
// behind it is what the module is for.
|
||||
self.expect_after_recovery(";", self.recovered_since(mark))?;
|
||||
let mut items = Vec::new();
|
||||
while !self.at_body_end(end_kw) {
|
||||
items.push(self.item_or_recover()?);
|
||||
@@ -326,11 +325,14 @@ impl<'a> Parser<'a> {
|
||||
self.bump();
|
||||
out.after_hash = self.take_gap();
|
||||
self.expect_sym("(")?;
|
||||
let mark = self.diags_mark();
|
||||
let mut list = Vec::new();
|
||||
self.take_list_directives(&mut out.directives, 0);
|
||||
if !self.cur().is_sym(")") {
|
||||
loop {
|
||||
let at = self.pos;
|
||||
list.push(self.element_or_recover(|p| p.parse_param_port())?);
|
||||
let recovered = list.last().is_some_and(ListElem::is_error);
|
||||
if let Some(ListElem::Ok(last)) = list.last_mut() {
|
||||
self.take_before_sep(&mut last.meta, ",");
|
||||
}
|
||||
@@ -348,13 +350,13 @@ impl<'a> Parser<'a> {
|
||||
// (`` `else``), or the arm may have been the tail of the list.
|
||||
// In tolerant mode the closing bracket decides on its own; see
|
||||
// [`Parser::list_ends`].
|
||||
if self.list_ends(comma, dirs.any) {
|
||||
if self.list_ends(at, comma, dirs.any, recovered) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
out.dangling = self.take_dangling();
|
||||
self.close_list(list.iter().any(ListElem::is_error))?;
|
||||
self.close_list(mark)?;
|
||||
out.ports = Some(list);
|
||||
Ok(out)
|
||||
}
|
||||
@@ -441,6 +443,7 @@ impl<'a> Parser<'a> {
|
||||
return Ok((PortList::None, Vec::new(), Vec::new()));
|
||||
}
|
||||
self.bump();
|
||||
let mark = self.diags_mark();
|
||||
// Directives before the first port. Harvested here rather than in the
|
||||
// loop below because both the ANSI/non-ANSI decision and the
|
||||
// written-but-empty check read the token after them.
|
||||
@@ -474,7 +477,9 @@ impl<'a> Parser<'a> {
|
||||
if ansi {
|
||||
let mut ports = Vec::new();
|
||||
loop {
|
||||
let at = self.pos;
|
||||
ports.push(self.element_or_recover(|p| p.parse_ansi_port())?);
|
||||
let recovered = ports.last().is_some_and(ListElem::is_error);
|
||||
if let Some(ListElem::Ok(last)) = ports.last_mut() {
|
||||
self.take_before_sep(&mut last.meta, ",");
|
||||
}
|
||||
@@ -486,13 +491,13 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
let dirs = self.take_list_directives(&mut directives, ports.len());
|
||||
if self.list_ends(comma, dirs.any) {
|
||||
if self.list_ends(at, comma, dirs.any, recovered) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Comments on their own lines before the `)` belong inside it.
|
||||
let dangling = self.take_dangling();
|
||||
self.close_list(ports.iter().any(ListElem::is_error))?;
|
||||
self.close_list(mark)?;
|
||||
// A trailing comment on the closing line belongs to the last
|
||||
// port — but only when the header did not write a `;` right
|
||||
// after the `)`. `module m (input a) /*c*/ ;` writes its comment
|
||||
@@ -509,18 +514,24 @@ impl<'a> Parser<'a> {
|
||||
} else {
|
||||
let mut ports = Vec::new();
|
||||
loop {
|
||||
let at = self.pos;
|
||||
ports.push(self.element_or_recover(|p| p.parse_non_ansi_port())?);
|
||||
let recovered = ports.last().is_some_and(ListElem::is_error);
|
||||
let comma = match ports.last() {
|
||||
Some(ListElem::Ok(last)) => last.comma,
|
||||
_ => false,
|
||||
// A non-ANSI port reads its own separator, so an error
|
||||
// element — which never got that far — leaves the `,` for
|
||||
// the list to take. Leaving it under the cursor was the
|
||||
// 2026-09-03 runaway: see the work log.
|
||||
_ => self.eat_sym(","),
|
||||
};
|
||||
let dirs = self.take_list_directives(&mut directives, ports.len());
|
||||
if self.list_ends(comma, dirs.any) {
|
||||
if self.list_ends(at, comma, dirs.any, recovered) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let dangling = self.take_dangling();
|
||||
self.close_list(ports.iter().any(ListElem::is_error))?;
|
||||
self.close_list(mark)?;
|
||||
Ok((PortList::NonAnsi(ports), dangling, directives))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user