WIP §32 header recovery — DO NOT MERGE: half-finished; a fuzz test loops without advancing and exhausts memory (crashed the machine 2026-09-03)
Checkpoint of the interrupted dev work (rate limit) so master stays clean. Known state: a_half_typed_instantiation_is_one_error_node (expected to invert) and tolerant_parse_equals_strict_parse_on_valid_ sources FAIL; the error_recovery test binary exceeds 6 GB under tools/guard.sh (a non-advancing recovery loop under the delete-any- character / truncate fuzzers). Resume in a worktree of this branch, under tools/guard.sh, fixing the advance guarantee first. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
4d70de1976
commit
6a15594ae8
50 files changed
+1135
-430
No files matched your search
@@ -268,12 +268,12 @@ impl<'a> Parser<'a> {
|
||||
self.take_list_directives(&mut param_directives, 0);
|
||||
if !self.cur().is_sym(")") {
|
||||
loop {
|
||||
list.push(self.parse_connection()?);
|
||||
if let Some(last) = list.last_mut() {
|
||||
list.push(self.element_or_recover(|p| p.parse_connection())?);
|
||||
if let Some(ListElem::Ok(last)) = list.last_mut() {
|
||||
self.take_before_sep(&mut last.meta, ",");
|
||||
}
|
||||
let comma = self.eat_sym(",");
|
||||
if let Some(last) = list.last_mut() {
|
||||
if let Some(ListElem::Ok(last)) = list.last_mut() {
|
||||
last.comma = comma;
|
||||
if comma && last.meta.trailing.is_none() {
|
||||
last.meta.trailing = self.take_trailing();
|
||||
@@ -285,7 +285,7 @@ impl<'a> Parser<'a> {
|
||||
// the list, and after a directive only the closing bracket
|
||||
// does — an `` `ifdef`` arm may end without a comma and
|
||||
// still be followed by an `` `else`` arm.
|
||||
if (!comma && !dirs.any) || (dirs.any && self.cur().is_sym(")")) {
|
||||
if self.list_ends(comma, dirs.any) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -293,11 +293,11 @@ impl<'a> Parser<'a> {
|
||||
// Comments before the `)` of the override list belong inside it.
|
||||
let n = list.len();
|
||||
self.take_last_entry_before_close(
|
||||
list.last_mut().map(|c| &mut c.meta),
|
||||
list.last_mut().and_then(|c| c.ok_mut()).map(|c| &mut c.meta),
|
||||
&mut param_directives,
|
||||
n,
|
||||
);
|
||||
self.expect_sym(")")?;
|
||||
self.close_list(list.iter().any(ListElem::is_error))?;
|
||||
params = Some(list);
|
||||
}
|
||||
let mut instances = Vec::new();
|
||||
@@ -310,7 +310,7 @@ impl<'a> Parser<'a> {
|
||||
self.expect_sym("(")?;
|
||||
let mut conn_directives = Vec::new();
|
||||
let conns = self.parse_connections(&mut conn_directives)?;
|
||||
self.expect_sym(")")?;
|
||||
self.close_list(conns.has_error())?;
|
||||
let span = self.span_from(start);
|
||||
self.take_before_sep(&mut meta, ",");
|
||||
let more = self.eat_sym(",");
|
||||
@@ -377,58 +377,70 @@ impl<'a> Parser<'a> {
|
||||
if self.at_named_connection() {
|
||||
let mut conns = Vec::new();
|
||||
loop {
|
||||
conns.push(self.parse_connection()?);
|
||||
if let Some(last) = conns.last_mut() {
|
||||
conns.push(self.element_or_recover(|p| p.parse_connection())?);
|
||||
if let Some(ListElem::Ok(last)) = conns.last_mut() {
|
||||
self.take_before_sep(&mut last.meta, ",");
|
||||
}
|
||||
let comma = self.eat_sym(",");
|
||||
if let Some(last) = conns.last_mut() {
|
||||
if let Some(ListElem::Ok(last)) = conns.last_mut() {
|
||||
last.comma = comma;
|
||||
if comma && last.meta.trailing.is_none() {
|
||||
last.meta.trailing = self.take_trailing();
|
||||
}
|
||||
}
|
||||
let dirs = self.take_list_directives(directives, conns.len());
|
||||
if (!comma && !dirs.any) || (dirs.any && self.cur().is_sym(")")) {
|
||||
if self.list_ends(comma, dirs.any) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Comments before the closing `)` belong to the last entry: after
|
||||
// it they would sit outside the connection list entirely.
|
||||
let n = conns.len();
|
||||
self.take_last_entry_before_close(conns.last_mut().map(|c| &mut c.meta), directives, n);
|
||||
let last = conns.last_mut().and_then(|c| c.ok_mut()).map(|c| &mut c.meta);
|
||||
self.take_last_entry_before_close(last, directives, n);
|
||||
Ok(Connections::Named(conns))
|
||||
} else {
|
||||
let mut conns = Vec::new();
|
||||
loop {
|
||||
let start = self.here();
|
||||
let meta = self.take_meta();
|
||||
let expr = if self.cur().is_sym(",") || self.cur().is_sym(")") {
|
||||
None
|
||||
} else {
|
||||
Some(self.parse_expr()?)
|
||||
conns.push(self.element_or_recover(|p| p.parse_ordered_connection())?);
|
||||
let comma = match conns.last() {
|
||||
Some(ListElem::Ok(last)) => last.comma,
|
||||
_ => self.eat_sym(","),
|
||||
};
|
||||
// An omitted connection (`u (a, , c)`) consumed no token, so
|
||||
// this is the empty span where it would have started.
|
||||
let span = self.span_from(start);
|
||||
let mut meta = meta;
|
||||
self.take_before_sep(&mut meta, ",");
|
||||
let comma = self.eat_sym(",");
|
||||
if comma {
|
||||
meta.trailing = self.take_trailing();
|
||||
}
|
||||
conns.push(OrderedConn { meta, expr, comma, span });
|
||||
let dirs = self.take_list_directives(directives, conns.len());
|
||||
if (!comma && !dirs.any) || (dirs.any && self.cur().is_sym(")")) {
|
||||
if self.list_ends(comma, dirs.any) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let n = conns.len();
|
||||
self.take_last_entry_before_close(conns.last_mut().map(|c| &mut c.meta), directives, n);
|
||||
let last = conns.last_mut().and_then(|c| c.ok_mut()).map(|c| &mut c.meta);
|
||||
self.take_last_entry_before_close(last, directives, n);
|
||||
Ok(Connections::Ordered(conns))
|
||||
}
|
||||
}
|
||||
|
||||
/// One positional connection (`u (a, , c)`), its separator included: an
|
||||
/// omitted one writes no token at all, so the `,` is the only thing that
|
||||
/// says it was there.
|
||||
fn parse_ordered_connection(&mut self) -> PResult<OrderedConn> {
|
||||
let start = self.here();
|
||||
let mut meta = self.take_meta();
|
||||
let expr = if self.cur().is_sym(",") || self.cur().is_sym(")") {
|
||||
None
|
||||
} else {
|
||||
Some(self.parse_expr()?)
|
||||
};
|
||||
// An omitted connection consumed no token, so this is the empty span
|
||||
// where it would have started.
|
||||
let span = self.span_from(start);
|
||||
self.take_before_sep(&mut meta, ",");
|
||||
let comma = self.eat_sym(",");
|
||||
if comma {
|
||||
meta.trailing = self.take_trailing();
|
||||
}
|
||||
Ok(OrderedConn { meta, expr, comma, span })
|
||||
}
|
||||
|
||||
/// True when the connection list starts with a named connection. The
|
||||
/// leading `(* ... *)` attributes of the first entry are looked past:
|
||||
/// they belong to the connection, not to the list.
|
||||
|
||||
Reference in new issue
Block a user