Type-name spans on the AST; vlog_semantic/src/scan.rs retired
ci / checks (push) Successful in 1m3s
ci / corpus (push) Successful in 33s

TODO §47 (docs/features/type-name-spans). Closes topo §2.9-2.

`DataType` carries `name_start` (a `u32` in its existing padding, so
`Expr` stays at its 96-byte pin) and derives `name_span()` and
`segments()` — the `::`/`.` split from the span's own text, with a
leading escaped identifier read to its terminator first. Five parser
construction sites set it; an implicit type gets the empty range at the
position its name would have had. `StmtKind::Disable { name, name_span }`.
The binder walks `ty.segments()` and verifies every segment's range
against the source before recording it (`exact_or_empty`); a segment that
does not read back is recorded with the empty range, never dropped, so
the census's `unplaced` counter is the alarm a join regression would
move (review rework of QA's MEDIUM). `scan.rs` deleted; `bind_data_type`
lost its `window` and ten call sites their window arithmetic.

Census unchanged in every field (860 files, 27 486 symbols, 103 870
references, 1 197 unresolved, 0 unplaced); 0 of 860 corpus files differ;
200/200 opentitan definition/hover/typeDefinition answers identical.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5.1 committed 2026-09-05 09:24:19 -05:00
1 parent 859742ac84
commit 4d59e80568
20 files changed
+855 -335

No files matched your search

+1 -1
View File
@@ -4798,7 +4798,7 @@ census, 21 485 symbols).
clean; release server smoke OK; census 27 486 symbols / 103 870
references / 0 unplaced, identical to a `v0.44.0` scratch worktree; 200
`definition` positions over opentitan identical old vs new
- [ ] QA: census re-derived; escaped and scoped type names; `iface.mp`
- [x] QA: census re-derived; escaped and scoped type names; `iface.mp`
ports; implicit types; definition/hover on type names over
opentitan (read-only)
+45
View File
@@ -552,6 +552,51 @@ mod tests {
assert_eq!(locations[0].range.start.line, 1);
}
/// A qualified type name is two references, each addressable on its own
/// half: the parser spans `pkg::t` and `DataType::segments` splits it, so
/// F12 on the *item* lands on the typedef rather than on the package.
#[test]
fn a_scoped_type_name_jumps_from_its_item_half() {
let text = "\
package pkg;
typedef logic [1:0] t;
endpackage
module m;
pkg::t x;
endmodule
";
let (ws, uri) = document(text);
let item = definition(&ws, &uri, at(text, "pkg::t x") + 5);
assert_eq!(item.len(), 1, "the typedef");
assert_eq!(item[0].range.start.line, 1, "the `typedef ... t;` line");
assert_eq!(item[0].range.start.character, 22, "the name `t`, not the keyword");
let unit = definition(&ws, &uri, at(text, "pkg::t x"));
assert_eq!(unit.len(), 1, "the package");
assert_eq!(unit[0].range.start.line, 0);
}
/// `bus_if.mp bus` — the interface is the type, so the head range is what
/// F12 answers from; the modport tail is a member of it.
#[test]
fn an_interface_port_type_jumps_from_its_head() {
let text = "\
interface bus_if;
logic clk;
modport mp (input clk);
endinterface
module m (bus_if.mp bus);
endmodule
";
let (ws, uri) = document(text);
let head = definition(&ws, &uri, at(text, "bus_if.mp bus") + 2);
assert_eq!(head.len(), 1, "the interface");
assert_eq!(head[0].range.start.line, 0);
assert_eq!(head[0].range.start.character, 10, "the interface name");
let tail = definition(&ws, &uri, at(text, "bus_if.mp bus") + 7);
assert_eq!(tail.len(), 1, "the modport");
assert_eq!(tail[0].range.start.line, 2);
}
#[test]
fn a_macro_use_jumps_to_its_define_in_the_same_file() {
let text = "`define WIDTH 8\nmodule m;\n logic [`WIDTH-1:0] a;\nendmodule\n";
+1 -1
View File
@@ -482,7 +482,7 @@ impl<'a> Fmt<'a> {
},
StmtKind::Break => concat(vec![text("break"), self.semi(before_semi)]),
StmtKind::Continue => concat(vec![text("continue"), self.semi(before_semi)]),
StmtKind::Disable(name) => {
StmtKind::Disable { name, .. } => {
concat(vec![text(format!("disable {}", named(name))), self.semi(before_semi)])
}
StmtKind::WaitFork => concat(vec![text("wait fork"), self.semi(before_semi)]),
@@ -58,7 +58,7 @@ impl Rule for DisableStatement {
let targets = disableable(ctx.file());
let mut out = Vec::new();
walk_all_stmts(ctx.file(), &mut |stmt| {
let StmtKind::Disable(name) = &stmt.kind else { return };
let StmtKind::Disable { name, .. } = &stmt.kind else { return };
// `disable fork` is the keyword form, not a label.
if name == "fork" || targets.contains(name.as_str()) {
return;
+76 -1
View File
@@ -5,7 +5,10 @@
use super::*;
/// A data type: keyword or user-defined name, plus signing and packed dims.
/// `name` may be empty for implicit types (`input [7:0] x`).
/// `name` may be empty for implicit types (`input [7:0] x`), and is the whole
/// chain a qualified type reference writes: `pkg::item`, `bus_if.mp`.
/// [`DataType::name_span`] says where it is written and
/// [`DataType::segments`] splits it.
#[derive(Debug, Clone, Default)]
pub struct DataType {
/// The `virtual` / `virtual interface` prefix of a virtual interface type
@@ -22,6 +25,14 @@ pub struct DataType {
/// so a rare field must not widen the common case.
pub virt: Option<VirtualKw>,
pub name: String,
/// Where [`DataType::name`] is written. Read it through
/// [`DataType::name_span`], which pairs it with the name's own length.
///
/// Four bytes rather than a whole [`TextRange`] because they fit in the
/// padding this struct already has: an eight-byte span pushes `DataType`
/// to 96 and, through [`ExprKind::Type`], every `Expr` to 104, past the
/// 96-byte pin in `size_pins`.
pub(crate) name_start: u32,
/// The rare tail of a type: parameterization or an anonymous aggregate
/// body. See [`TypeExtra`]; read it through [`DataType::params`] /
/// [`DataType::inline`].
@@ -57,6 +68,70 @@ impl DataType {
_ => None,
}
}
/// The byte range [`DataType::name`] occupies: `src[name_span] == name`
/// for every name the source spells the way the AST joined it, which is
/// every name but the pathological spacings [`DataType::segments`]
/// documents. An implicit type has no name, so this is the empty range at
/// the position a name would have been written — the same convention an
/// unnamed DPI formal's `name_span` uses.
pub fn name_span(&self) -> TextRange {
TextRange::new(self.name_start, self.name_start.saturating_add(self.name.len() as u32))
}
/// The `::`- and `.`-separated segments of the name — `pkg`, `item` of
/// `pkg::item`; `bus_if`, `mp` of `bus_if.mp` — each with the byte range
/// it occupies.
///
/// Derived from [`DataType::name_span`] and the name's own text: the
/// construct is never rescanned. So a source that spells the name
/// differently from the way the parser joined it — an escaped segment
/// terminated by a newline rather than a space, a `bus_if . mp` written
/// apart — hands back ranges that do not slice back to their segment.
/// A caller that must not mislocate checks the slice and drops the
/// segment; `vlog_semantic`'s binder does.
pub fn segments(&self) -> impl Iterator<Item = (&str, TextRange)> + '_ {
let base = self.name_start;
let mut rest = Some((0usize, self.name.as_str()));
std::iter::from_fn(move || {
let (at, text) = rest.take()?;
let (seg, tail) = match separator(text) {
Some((i, len)) => (&text[..i], Some((at + i + len, &text[i + len..]))),
None => (text, None),
};
rest = tail;
let start = base.saturating_add(at as u32);
Some((seg, TextRange::new(start, start.saturating_add(seg.len() as u32))))
})
.filter(|(seg, _): &(&str, TextRange)| !seg.is_empty())
}
}
/// Where the first `::`/`.` that separates two name segments starts, and how
/// many bytes it is.
///
/// An escaped identifier swallows both spellings (`\a.b ::x` is two segments,
/// not three), so one that leads the text runs to its terminating whitespace —
/// which the parser keeps in the joined name (§29) — before the search for a
/// separator begins.
fn separator(text: &str) -> Option<(usize, usize)> {
let bytes = text.as_bytes();
let mut i = 0;
if bytes.first() == Some(&b'\\') {
while i < bytes.len() && !bytes[i].is_ascii_whitespace() {
i += 1;
}
// The terminator belongs to the segment; anything else is a separator.
i = (i + 1).min(bytes.len());
}
while i < bytes.len() {
match bytes[i] {
b':' if bytes.get(i + 1) == Some(&b':') => return Some((i, 2)),
b'.' => return Some((i, 1)),
_ => i += 1,
}
}
None
}
/// What a type carries beyond its name, signing and packed dimensions. A type
+9 -2
View File
@@ -266,7 +266,14 @@ pub enum StmtKind {
},
Break,
Continue,
Disable(String),
/// `disable blk;`, `disable fork;` — the label or task the statement
/// names, with the range it is written in. A *use*, not a declaration,
/// but it is addressable all the same, so it carries a span like every
/// other name (`disable fork` spans the `fork` keyword).
Disable {
name: String,
name_span: TextRange,
},
Directive(RawText),
/// Macro invocation used as a statement.
MacroStmt(MacroCall),
@@ -323,7 +330,7 @@ impl StmtKind {
| StmtKind::Return { .. }
| StmtKind::Break
| StmtKind::Continue
| StmtKind::Disable(_)
| StmtKind::Disable { .. }
| StmtKind::WaitFork
| StmtKind::DoWhile { .. } => true,
StmtKind::Timing { stmt, .. } => stmt.is_none(),
+22 -16
View File
@@ -10,14 +10,26 @@ use super::item::MEMBER_QUALIFIERS;
use super::*;
impl<'a> Parser<'a> {
/// A type with nothing written for it, spanning the empty range at the
/// cursor: what a `parameter type T` and an implicit `input [7:0] x`
/// both carry. Distinct from [`DataType::default`] only in that its
/// `name_span` points at the source rather than at offset zero.
pub(super) fn implicit_type(&self) -> DataType {
DataType { name_start: self.here(), ..DataType::default() }
}
/// Parse a possibly-implicit data type. Stops before the declarator name.
pub(super) fn parse_opt_data_type(&mut self) -> PResult<DataType> {
let mut ty = DataType::default();
// An implicit type writes no name at all, so its `name_span` is the
// empty range where a name would have gone: right here, before
// anything of the type has been consumed.
let mut ty = self.implicit_type();
// `property p(sequence a, property b);` — inside a property's or a
// sequence's formal list, and nowhere else, the two keywords name a
// formal's *type* (IEEE 1800 §16.8). `untyped` needs no case: it is
// an ordinary identifier and already reads as a user-defined type.
if self.sva_formals && (self.cur().is_kw("sequence") || self.cur().is_kw("property")) {
ty.name_start = self.here();
ty.name = self.bump().text;
return Ok(ty);
}
@@ -35,7 +47,9 @@ impl<'a> Parser<'a> {
// Glued onto the interface name exactly as an interface *port*'s
// modport is, so every consumer still sees one type-name string.
if self.at_modport_port() {
ty.name = self.parse_modport_port_type()?.name;
let head = self.parse_modport_port_type()?;
ty.name = head.name;
ty.name_start = head.name_start;
return Ok(ty);
}
}
@@ -53,18 +67,15 @@ impl<'a> Parser<'a> {
return Ok(ty);
}
if t.kind == TokenKind::Keyword && TYPE_KEYWORDS.contains(&t.text.as_str()) {
ty.name_start = self.here();
ty.name = self.bump().text;
} else if t.kind == TokenKind::Ident {
// User-defined type only if what follows still leaves an
// identifier for the declarator name.
if self.at_typed_declarator() {
let mut name = self.expect_ident()?;
while self.cur().is_sym("::") {
self.bump();
let segment = self.expect_ident()?;
Self::push_scope_segment(&mut name, &segment);
}
let (name, span) = self.parse_scoped_name()?;
ty.name = name;
ty.name_start = span.start;
if self.at_type_params() {
ty.extra = Some(Box::new(TypeExtra::Params(self.parse_type_params()?)));
}
@@ -187,7 +198,7 @@ impl<'a> Parser<'a> {
// parameter outside the `#( ... )` list
// (lossy_valid_to_stream_tb.sv:26). Its default is a type, not a value.
let is_type = self.eat_kw("type");
let ty = if is_type { DataType::default() } else { self.parse_opt_data_type()? };
let ty = if is_type { self.implicit_type() } else { self.parse_opt_data_type()? };
let declarators = self.parse_declarator_list(is_type)?;
Ok(ParamDecl { kw, after_kw, is_type, ty, declarators })
}
@@ -474,13 +485,8 @@ impl<'a> Parser<'a> {
if !ty.is_implicit() || self.cur().kind != TokenKind::Ident {
return Ok(ty);
}
let mut name = self.expect_ident()?;
while self.cur().is_sym("::") {
self.bump();
let segment = self.expect_ident()?;
Self::push_scope_segment(&mut name, &segment);
}
let mut ty = DataType { name, ..DataType::default() };
let (name, span) = self.parse_scoped_name()?;
let mut ty = DataType { name, name_start: span.start, ..DataType::default() };
if self.at_type_params() {
ty.extra = Some(Box::new(TypeExtra::Params(self.parse_type_params()?)));
}
@@ -167,18 +167,21 @@ impl<'a> Parser<'a> {
// `disable fork;` kills every process the enclosing `fork`
// started; `fork` is a keyword, not a block name.
if self.cur().is_kw("fork") {
let name_span = self.cur().span;
self.bump();
self.expect_stmt_semi()?;
return Ok(StmtKind::Disable("fork".to_string()));
return Ok(StmtKind::Disable { name: "fork".to_string(), name_span });
}
let start = self.here();
let mut name = self.expect_ident()?;
while self.cur().is_sym(".") {
self.bump();
name.push('.');
name.push_str(&self.expect_ident()?);
}
let name_span = self.span_from(start);
self.expect_stmt_semi()?;
Ok(StmtKind::Disable(name))
Ok(StmtKind::Disable { name, name_span })
}
"wait" => {
self.bump();
+6 -3
View File
@@ -412,7 +412,7 @@ impl<'a> Parser<'a> {
meta,
kw,
after_kw,
ty: DataType::default(),
ty: self.implicit_type(),
is_type: true,
before_name,
name,
@@ -624,12 +624,15 @@ impl<'a> Parser<'a> {
/// The `bus_if.mp` of an interface port, as its type. The modport is glued
/// onto the interface name exactly as a `pkg::` qualifier is, so every
/// consumer that prints or scans a type name still sees one string.
/// consumer that prints a type name still sees one string;
/// [`DataType::segments`] splits it back into its two halves and their
/// ranges.
pub(super) fn parse_modport_port_type(&mut self) -> PResult<DataType> {
let name_start = self.here();
let mut name = self.expect_ident()?;
self.expect_sym(".")?;
name.push('.');
name.push_str(&self.expect_ident()?);
Ok(DataType { name, ..DataType::default() })
Ok(DataType { name, name_start, ..DataType::default() })
}
}
+117 -1
View File
@@ -1011,10 +1011,12 @@ fn check_stmt(src: &str, stmt: &Stmt, parent: TextRange) {
check_stmt(src, inner, here);
}
StmtKind::Import(paths) => check_import_paths(src, paths, here),
StmtKind::Disable { name, name_span } => {
check_name(src, "disable target", name, *name_span, here)
}
StmtKind::Break
| StmtKind::Continue
| StmtKind::WaitFork
| StmtKind::Disable(_)
| StmtKind::Null
| StmtKind::Error(_) => {}
StmtKind::Assertion(a) => check_assertion(src, a, here),
@@ -1669,3 +1671,117 @@ fn check_constraint_set(src: &str, set: &ConstraintSet, parent: TextRange) {
}
}
}
// ----------------------------------------------------------------------
// Type-name spans (TODO.md §47)
// ----------------------------------------------------------------------
/// Every `DataType` a source file writes, in item order, with the declarator
/// it belongs to left behind — enough to reach each construction site by hand.
fn module_types(file: &SourceFile) -> Vec<&DataType> {
let ItemKind::Module(m) = &file.items[0].kind else { panic!("expected a module") };
let mut out = Vec::new();
if let PortList::Ansi(ports) = &m.ports {
out.extend(ports.iter().filter_map(ListElem::ok).map(|p| &p.ty));
}
for item in &m.items {
match &item.kind {
ItemKind::DataDecl(d) => out.push(&d.ty),
ItemKind::Typedef(t) => {
if let TypedefKind::Alias(ty) = &t.kind {
out.push(ty);
}
}
_ => {}
}
}
out
}
#[test]
fn a_type_name_span_slices_back_to_the_name_as_written() {
let src = "\
module m (input bus_if.mp bus, input [7:0] raw);
typedef pkg_a::state_t alias_t;
logic [3:0] plain;
my_type_t user;
virtual clk_rst_if vif;
endmodule
";
let file = parse_source(src).expect("parse error");
let types = module_types(&file);
let seen: Vec<&str> = types.iter().map(|ty| slice(src, ty.name_span())).collect();
assert_eq!(seen, ["bus_if.mp", "", "pkg_a::state_t", "logic", "my_type_t", "clk_rst_if"]);
for ty in &types {
assert_eq!(slice(src, ty.name_span()), ty.name, "a type-name span moved off its name");
}
// The implicit `input [7:0] raw` has no name, so its span is the empty
// range where one would have been written — at the `[`.
let implicit = types[1].name_span();
assert!(implicit.is_empty());
assert_eq!(&src[implicit.start as usize..implicit.start as usize + 1], "[");
}
#[test]
fn segments_split_a_qualified_type_name_without_rescanning() {
let src = "\
module m (input bus_if.mp bus);
pkg_a::state_t s;
logic plain;
endmodule
";
let file = parse_source(src).expect("parse error");
let types = module_types(&file);
let split = |ty: &DataType| -> Vec<(String, String)> {
ty.segments().map(|(seg, span)| (seg.to_string(), slice(src, span).to_string())).collect()
};
assert_eq!(split(types[0]), [("bus_if".into(), "bus_if".into()), ("mp".into(), "mp".into())]);
assert_eq!(
split(types[1]),
[("pkg_a".into(), "pkg_a".into()), ("state_t".into(), "state_t".into())]
);
assert_eq!(split(types[2]), [("logic".to_string(), "logic".to_string())]);
// An implicit type has no name and so no segments at all.
let empty = DataType::default();
assert_eq!(empty.segments().count(), 0);
}
#[test]
fn an_escaped_segment_keeps_its_terminating_space_in_span_and_segment() {
// §29: the parser joins `\a+b ::state_t` with the space the escaped
// identifier needs, so the joined name is what the source spells and the
// first segment carries the terminator.
let src = "module m;\n \\a+b ::state_t s;\nendmodule\n";
let file = parse_source(src).expect("parse error");
let types = module_types(&file);
assert_eq!(types[0].name, "\\a+b ::state_t");
assert_eq!(slice(src, types[0].name_span()), "\\a+b ::state_t");
let segs: Vec<&str> = types[0].segments().map(|(_, span)| slice(src, span)).collect();
assert_eq!(segs, ["\\a+b ", "state_t"]);
}
#[test]
fn a_disable_names_its_target_with_a_span() {
let src = "\
module m;
initial begin : blk
disable blk;
disable fork;
end
endmodule
";
let file = parse_source(src).expect("parse error");
let ItemKind::Module(m) = &file.items[0].kind else { panic!("expected a module") };
let ItemKind::Initial(outer) = &m.items[0].kind else { panic!("expected an initial") };
let StmtKind::Block { stmts, .. } = &outer.kind else { panic!("expected a block") };
let targets: Vec<&str> = stmts
.iter()
.map(|s| {
let StmtKind::Disable { name_span, .. } = &s.kind else { panic!("expected a disable") };
slice(src, *name_span)
})
.collect();
assert_eq!(targets, ["blk", "fork"]);
}
+1 -1
View File
@@ -352,7 +352,7 @@ impl<'a> Binder<'a> {
// Return type, arguments and body all resolve from inside the class,
// as the LRM says an out-of-body declaration does.
if let Some(ret) = ret {
self.bind_data_type(ret, TextRange::new(span.start, name_span.start), body);
self.bind_data_type(ret, body);
}
self.bind_tf_args(args, body);
self.bind_stmts(stmts, body);
+52 -70
View File
@@ -9,7 +9,6 @@ use vlog_parser::span::TextRange;
use vlog_parser::token::is_keyword;
use crate::model::{ScopeId, ScopeKind, SymbolId, SymbolKind};
use crate::scan::NameScanner;
use super::{type_name_of, Binder, Target};
@@ -39,7 +38,7 @@ impl<'a> Binder<'a> {
if let Some(written) = &p.kw {
kw.clone_from(written);
}
self.bind_data_type(&p.ty, TextRange::new(p.span.start, p.name_span.start), scope);
self.bind_data_type(&p.ty, scope);
let ty = p.unpacked.is_empty().then_some(&p.ty);
self.declare_typed(scope, &p.name, param_kind(&kw), p.name_span, p.span, ty);
self.bind_dims(&p.unpacked, scope);
@@ -51,7 +50,7 @@ impl<'a> Binder<'a> {
/// in [`Binder::bind_param_ports`].
pub(super) fn bind_tf_args(&mut self, args: &'a [ListElem<TfArg>], scope: ScopeId) {
for a in args.iter().filter_map(ListElem::ok) {
self.bind_data_type(&a.ty, TextRange::new(a.span.start, a.name_span.start), scope);
self.bind_data_type(&a.ty, scope);
let ty = a.unpacked.is_empty().then_some(&a.ty);
self.declare_typed(scope, &a.name, SymbolKind::TfArg, a.name_span, a.span, ty);
self.bind_dims(&a.unpacked, scope);
@@ -68,13 +67,13 @@ impl<'a> Binder<'a> {
// a container, not a value of the type, and is left untyped on
// the same rule every other unpacked declarator follows.
TypedefKind::Alias(ty) => {
self.bind_data_type(ty, TextRange::new(span.start, ns.start), scope);
self.bind_data_type(ty, scope);
let ty = t.unpacked.is_empty().then_some(ty);
self.declare_typed(scope, &t.name, SymbolKind::Typedef, ns, span, ty);
}
TypedefKind::Enum(e) => {
self.declare(scope, &t.name, SymbolKind::Typedef, ns, span);
self.bind_enum_body(e, TextRange::new(span.start, ns.start), scope);
self.bind_enum_body(e, scope);
}
TypedefKind::Struct(s) => {
let inner = self.declare_with_scope(
@@ -103,9 +102,9 @@ impl<'a> Binder<'a> {
/// which is why `IDLE` is written bare. One function for all three
/// spellings that can write one: `typedef enum {…} e_t;`, an anonymous
/// `enum {…} x;`, and an anonymous enum standing as a struct member's type.
fn bind_enum_body(&mut self, e: &EnumType, window: TextRange, scope: ScopeId) {
fn bind_enum_body(&mut self, e: &EnumType, scope: ScopeId) {
if let Some(base) = &e.base {
self.bind_data_type(base, window, scope);
self.bind_data_type(base, scope);
}
self.bind_enum_members(&e.members, scope);
}
@@ -130,8 +129,7 @@ impl<'a> Binder<'a> {
/// rather than once per declarator.
fn bind_struct_uses(&mut self, s: &StructType, scope: ScopeId) {
for m in &s.members {
let first = m.declarators.first().map(|d| d.span.start).unwrap_or(m.span.end);
self.bind_data_type(&m.ty, TextRange::new(m.span.start, first), scope);
self.bind_data_type(&m.ty, scope);
for d in &m.declarators {
self.bind_dims(&d.unpacked, scope);
self.bind_opt_expr(d.init.as_ref(), scope);
@@ -177,10 +175,10 @@ impl<'a> Binder<'a> {
}
}
pub(super) fn bind_data_decl(&mut self, d: &DataDecl, span: TextRange, scope: ScopeId) {
pub(super) fn bind_data_decl(&mut self, d: &DataDecl, scope: ScopeId) {
let kind = if d.net.is_some() { SymbolKind::Net } else { SymbolKind::Var };
self.bind_opt_expr(d.delay.as_ref().map(|n| &n.expr), scope);
self.bind_declarators(&d.declarators, kind, &d.ty, span, scope);
self.bind_declarators(&d.declarators, kind, &d.ty, scope);
}
pub(super) fn bind_port_decl(&mut self, p: &PortDecl, span: TextRange, scope: ScopeId) {
@@ -222,7 +220,7 @@ impl<'a> Binder<'a> {
symbol.type_name = type_name;
}
}
self.bind_declarators(&p.declarators, kind, &p.ty, span, scope);
self.bind_declarators(&p.declarators, kind, &p.ty, scope);
}
pub(super) fn bind_declarators(
@@ -230,11 +228,9 @@ impl<'a> Binder<'a> {
declarators: &[Declarator],
kind: SymbolKind,
ty: &DataType,
span: TextRange,
scope: ScopeId,
) {
let first = declarators.first().map(|d| d.span.start).unwrap_or(span.end);
self.bind_data_type(ty, TextRange::new(span.start, first), scope);
self.bind_data_type(ty, scope);
for d in declarators {
let plain = d.unpacked.is_empty();
let id =
@@ -254,49 +250,12 @@ impl<'a> Binder<'a> {
}
}
/// A user-defined type name is a use like any other. `window` is the
/// source range the name was written in — everything before the declared
/// name, which is where a data type always sits. A `DataType` has no span
/// of its own (vlog-semantic handshake item 2, still open), so this is
/// the one declaration surface still located by scanning.
pub(super) fn bind_data_type(&mut self, ty: &DataType, window: TextRange, scope: ScopeId) {
/// A user-defined type name is a use like any other, and the parser hands
/// over where every segment of it is written
/// ([`DataType::segments`]), so nothing here rescans the source.
pub(super) fn bind_data_type(&mut self, ty: &DataType, scope: ScopeId) {
if !ty.name.is_empty() && !is_keyword(&ty.name) {
match ty.name.split_once("::") {
Some((unit, item)) => {
let mut scanner = NameScanner::new(self.src, window);
let unit_span = scanner.find(unit).unwrap_or(TextRange::empty(window.start));
let item_span = scanner.find(item).unwrap_or(TextRange::empty(window.start));
self.use_name(scope, unit, unit_span, Target::Unit);
self.use_name(scope, item, item_span, Target::UnitMember(unit.to_string()));
}
// `bus_if.mp bus`, `virtual bus_if.mp vif` — the parser glues
// an interface port's modport onto the type name (IEEE 1800
// §25.4, §25.9). The interface is the type and the modport is
// a **member** of it, so both halves are bound: the head as
// any other type name, the tail against the interface's own
// scope (or, cross-file, as `bus_if::mp` in the workspace's
// member table). "The tail is where to bind them" —
// `docs/features/ansi-first-port/README.md`.
None => {
let (name, modport) = match ty.name.split_once('.') {
Some((iface, modport)) => (iface, Some(modport)),
None => (ty.name.as_str(), None),
};
let ns = crate::scan::name_span(self.src, window, name);
self.use_name(scope, name, ns, Target::Type);
if let Some(modport) = modport {
let tail = self.modport_tail(ns, modport);
if !tail.is_empty() {
self.use_member(
scope,
modport,
tail,
Target::TypeMember { unit: name.to_string() },
);
}
}
}
}
self.bind_type_name(ty, scope);
}
self.bind_dims(&ty.packed, scope);
// An anonymous aggregate written where a type name would go. Its
@@ -305,27 +264,50 @@ impl<'a> Binder<'a> {
// is written here is every use inside it, recorded once for the type
// however many declarators share it.
match ty.inline() {
Some(TypeExtra::Enum(e)) => self.bind_enum_body(e, window, scope),
Some(TypeExtra::Enum(e)) => self.bind_enum_body(e, scope),
Some(TypeExtra::Struct(s)) => self.bind_struct_uses(s, scope),
_ => {}
}
}
/// The byte range of the `mp` in a glued `bus_if.mp` type name, given the
/// range the interface half was located at.
/// The segments of a written type name, each recorded as a use.
///
/// Derived rather than received — a `DataType` carries no spans at all —
/// so it is verified twice over: the byte after the interface half must be
/// a literal `.`, and the bytes after that must spell the modport exactly.
/// A source that wrote the two apart, or a name a macro produced, costs the
/// `pkg::item` is a unit and a member of it. `bus_if.mp bus`,
/// `virtual bus_if.mp vif` — the parser glues an interface port's modport
/// onto the type name (IEEE 1800 §25.4, §25.9) — is the interface as the
/// type plus the modport as a **member** of it, bound against the
/// interface's own scope (or, cross-file, as `bus_if::mp` in the
/// workspace's member table). "The tail is where to bind them" —
/// `docs/features/ansi-first-port/README.md`.
///
/// Every span is checked against the source before it is recorded, the
/// rule the modport tail has always followed: a name the source spells
/// differently from the way the parser joined it — an escaped segment
/// terminated by a newline, a `bus_if . mp` written apart — costs the
/// reference and never mislocates it.
fn modport_tail(&self, iface: TextRange, modport: &str) -> TextRange {
if iface.is_empty() || self.src.as_bytes().get(iface.end as usize) != Some(&b'.') {
return TextRange::empty(iface.end);
fn bind_type_name(&mut self, ty: &DataType, scope: ScopeId) {
let scoped = ty.name.contains("::");
let mut head: Option<&str> = None;
for (seg, span) in ty.segments() {
// A segment whose derived range does not read back as its own
// text (`pkg :: item`, a comment inside the name) is recorded
// with the empty range at its start, never dropped: an empty
// range is what the corpus census counts as *unplaced*, so a
// parser regression in the join would trip that alarm instead of
// silently lowering the resolution rate (§47's QA).
let span = self.exact_or_empty(span, seg);
match (head, scoped) {
(None, true) => self.use_name(scope, seg, span, Target::Unit),
(None, false) => self.use_name(scope, seg, span, Target::Type),
(Some(unit), true) => {
self.use_name(scope, seg, span, Target::UnitMember(unit.to_string()))
}
(Some(unit), false) => {
self.use_member(scope, seg, span, Target::TypeMember { unit: unit.to_string() })
}
}
head = Some(seg);
}
let start = iface.end.saturating_add(1);
let span = TextRange::new(start, start.saturating_add(modport.len() as u32));
self.exact_or_empty(span, modport)
}
}
+1 -1
View File
@@ -174,7 +174,7 @@ impl<'a> Binder<'a> {
// is the callee's formal, which this crate does not model (the
// same rule connection port names follow).
ExprKind::NamedArg { value, .. } => self.bind_expr(value, scope),
ExprKind::Type(ty) => self.bind_data_type(ty, e.span, scope),
ExprKind::Type(ty) => self.bind_data_type(ty, scope),
ExprKind::MinTypMax { min, typ, max, .. } => {
self.bind_expr(min, scope);
self.bind_expr(typ, scope);
+5 -9
View File
@@ -88,9 +88,9 @@ impl<'a> Binder<'a> {
}
ItemKind::Typedef(t) => self.bind_typedef(t, item.span, scope),
ItemKind::ParamDecl(p) => {
self.bind_declarators(&p.declarators, param_kind(&p.kw), &p.ty, item.span, scope)
self.bind_declarators(&p.declarators, param_kind(&p.kw), &p.ty, scope)
}
ItemKind::DataDecl(d) => self.bind_data_decl(d, item.span, scope),
ItemKind::DataDecl(d) => self.bind_data_decl(d, scope),
ItemKind::PortDecl(p) => self.bind_port_decl(p, item.span, scope),
ItemKind::ContAssign(c) => {
self.bind_opt_expr(c.delay.as_ref(), scope);
@@ -212,11 +212,7 @@ impl<'a> Binder<'a> {
// declares nothing, exactly as an `ItemKind::Error` does.
PortList::Ansi(ports) => {
for p in ports.iter().filter_map(ListElem::ok) {
self.bind_data_type(
&p.ty,
TextRange::new(p.span.start, p.name_span.start),
inner,
);
self.bind_data_type(&p.ty, inner);
self.declare_typed(
inner,
&p.name,
@@ -419,7 +415,7 @@ impl<'a> Binder<'a> {
return;
}
if let Some(ret) = &f.ret {
self.bind_data_type(ret, TextRange::new(span.start, f.name_span.start), scope);
self.bind_data_type(ret, scope);
}
let inner = self.declare_with_scope(
scope,
@@ -487,7 +483,7 @@ impl<'a> Binder<'a> {
fn bind_modport_prototype(&mut self, p: &'a TfPrototype, span: TextRange, scope: ScopeId) {
self.use_name(scope, &p.name, p.name_span, Target::InScope);
if let Some(ret) = &p.ret {
self.bind_data_type(ret, TextRange::new(span.start, p.name_span.start), scope);
self.bind_data_type(ret, scope);
}
let inner = self.new_scope(ScopeKind::Block, scope, span);
self.bind_tf_args(&p.args, inner);
+12 -14
View File
@@ -4,10 +4,8 @@
//! covergroups and property specs share with them.
use vlog_parser::ast::*;
use vlog_parser::span::TextRange;
use crate::model::{ScopeId, ScopeKind, SymbolKind};
use crate::scan::name_after_kw;
use super::decl::param_kind;
use super::{Binder, Target};
@@ -66,11 +64,7 @@ impl<'a> Binder<'a> {
match &i.ty {
Some(ty) => {
if let ExprKind::Ident(name) = &i.assign.lhs.kind {
self.bind_data_type(
ty,
TextRange::new(stmt.span.start, i.assign.lhs.span.start),
scope,
);
self.bind_data_type(ty, scope);
self.declare(
inner,
name,
@@ -140,21 +134,25 @@ impl<'a> Binder<'a> {
}
}
StmtKind::ExprStmt(e) | StmtKind::EventTrigger(e) => self.bind_expr(e, scope),
StmtKind::VarDecl(d) => self.bind_data_decl(d, stmt.span, scope),
StmtKind::VarDecl(d) => self.bind_data_decl(d, scope),
// A block-scoped type binds exactly as an item-level one does; the
// scope it lands in is the enclosing block's, which is what
// IEEE 1800 §6.18 asks for.
StmtKind::Typedef(t) => self.bind_typedef(t, stmt.span, scope),
StmtKind::ParamDecl(p) => {
self.bind_declarators(&p.declarators, param_kind(&p.kw), &p.ty, stmt.span, scope)
self.bind_declarators(&p.declarators, param_kind(&p.kw), &p.ty, scope)
}
StmtKind::PortDecl(p) => self.bind_port_decl(p, stmt.span, scope),
StmtKind::Return { expr: e, .. } => self.bind_opt_expr(e.as_ref(), scope),
StmtKind::Disable(name) => {
// A use, not a declaration, so name-spans deliberately gave it
// no range — the one statement still located by scanning.
let ns = name_after_kw(self.src, stmt.span, "disable", name);
self.use_name(scope, name, ns, Target::Lexical);
StmtKind::Disable { name, name_span } => {
// A use, not a declaration, but the parser spans it like any
// other name. Checked before it is recorded, the rule every
// derived span here follows: `disable a . b` written apart
// costs the reference rather than mislocating it.
let ns = self.exact_or_empty(*name_span, name);
if !ns.is_empty() {
self.use_name(scope, name, ns, Target::Lexical);
}
}
StmtKind::Assert { cond, then, els, .. } => {
self.bind_expr(cond, scope);
-1
View File
@@ -22,7 +22,6 @@ mod facts;
pub mod instantiations;
mod model;
mod resolve;
mod scan;
pub mod words;
mod workspace;
-193
View File
@@ -1,193 +0,0 @@
//! Recovering the byte range of a name the AST kept only as a `String`.
//!
//! Most declarations in `vlog_parser`'s AST store their name as a plain
//! `String` and give a span only for the whole construct (`module m ... `,
//! `input logic [W-1:0] d`). A language server needs the range of the *name*,
//! so this scans the construct's own source text for it. See the README's
//! Handshakes section: once the parser carries `name_span` on those nodes,
//! this module goes away.
use vlog_parser::span::TextRange;
/// A cursor over one source window that hands out the ranges of successive
/// identifiers, skipping comments, strings and macro invocations.
pub(crate) struct NameScanner<'a> {
src: &'a [u8],
pos: usize,
end: usize,
}
impl<'a> NameScanner<'a> {
/// A scanner over `window` of `src`.
pub(crate) fn new(src: &'a str, window: TextRange) -> Self {
let end = (window.end as usize).min(src.len());
let pos = (window.start as usize).min(end);
NameScanner { src: src.as_bytes(), pos, end }
}
/// The range of the next whole-word `name`, or `None` if the window holds
/// no more. The cursor moves past what it returns, so repeated calls walk
/// a list (`genvar i, j;`) left to right.
pub(crate) fn find(&mut self, name: &str) -> Option<TextRange> {
while let Some(word) = self.next_word() {
if &self.src[word.as_range()] == name.as_bytes() {
return Some(word);
}
}
None
}
/// The range of the next identifier of any spelling.
fn next_word(&mut self) -> Option<TextRange> {
while self.pos < self.end {
let b = self.src[self.pos];
match b {
b'/' if self.peek(1) == Some(b'/') => self.skip_line(),
b'/' if self.peek(1) == Some(b'*') => self.skip_block_comment(),
b'"' => self.skip_string(),
// A macro invocation is one opaque token: `` `WIDTH `` must
// not answer a search for the identifier `WIDTH`.
b'`' => {
self.pos += 1;
self.skip_word();
}
_ if is_ident_start(b) => {
let start = self.pos;
self.skip_word();
return Some(TextRange::new(start as u32, self.pos as u32));
}
_ => self.pos += 1,
}
}
None
}
fn peek(&self, n: usize) -> Option<u8> {
self.src.get(self.pos + n).copied()
}
fn skip_word(&mut self) {
// An escaped identifier (`\a+b `) runs to the next whitespace.
if self.src.get(self.pos) == Some(&b'\\') {
self.pos += 1;
while self.pos < self.end && !self.src[self.pos].is_ascii_whitespace() {
self.pos += 1;
}
return;
}
while self.pos < self.end && is_ident_continue(self.src[self.pos]) {
self.pos += 1;
}
}
fn skip_line(&mut self) {
while self.pos < self.end && self.src[self.pos] != b'\n' {
self.pos += 1;
}
}
fn skip_block_comment(&mut self) {
self.pos += 2;
while self.pos < self.end {
if self.src[self.pos] == b'*' && self.peek(1) == Some(b'/') {
self.pos += 2;
return;
}
self.pos += 1;
}
}
fn skip_string(&mut self) {
self.pos += 1;
while self.pos < self.end {
match self.src[self.pos] {
b'\\' => self.pos += 2,
b'"' => {
self.pos += 1;
return;
}
_ => self.pos += 1,
}
}
}
}
fn is_ident_start(b: u8) -> bool {
b.is_ascii_alphabetic() || b == b'_' || b == b'$' || b == b'\\'
}
fn is_ident_continue(b: u8) -> bool {
b.is_ascii_alphanumeric() || b == b'_' || b == b'$'
}
/// The range of `name` inside `window`, or an empty range at the window start
/// when the scan comes up empty (a name the source spells differently — an
/// escaped identifier, or text a macro produced).
pub(crate) fn name_span(src: &str, window: TextRange, name: &str) -> TextRange {
NameScanner::new(src, window).find(name).unwrap_or(TextRange::empty(window.start))
}
/// The range of `name` written *after* the first `kw` in `window`. Used where
/// the construct starts with a keyword and the name follows it, possibly
/// past qualifiers (`function automatic int f`).
pub(crate) fn name_after_kw(src: &str, window: TextRange, kw: &str, name: &str) -> TextRange {
let mut scanner = NameScanner::new(src, window);
if scanner.find(kw).is_none() {
return TextRange::empty(window.start);
}
scanner.find(name).unwrap_or(TextRange::empty(window.start))
}
#[cfg(test)]
mod tests {
use super::*;
fn whole(src: &str) -> TextRange {
TextRange::new(0, src.len() as u32)
}
#[test]
fn finds_a_name_after_its_keyword() {
let src = "module top (input a);";
let span = name_after_kw(src, whole(src), "module", "top");
assert_eq!(&src[span.as_range()], "top");
assert_eq!(span.start, 7);
}
#[test]
fn skips_comments_and_strings() {
let src = "/* d */ \"d\" // d\n d;";
let span = name_span(src, whole(src), "d");
assert_eq!(span.start, 18);
}
#[test]
fn matches_whole_words_only() {
let src = "input wire [W-1:0] w;";
let span = name_span(src, whole(src), "w");
assert_eq!(&src[span.as_range()], "w");
assert_eq!(span.start, 19);
}
#[test]
fn a_macro_invocation_is_one_opaque_token() {
let src = "`WIDTH WIDTH";
let span = name_span(src, whole(src), "WIDTH");
assert_eq!(span.start, 7);
}
#[test]
fn a_name_that_is_not_there_gives_an_empty_range() {
let src = "module m;";
let span = name_span(src, whole(src), "nope");
assert!(span.is_empty());
}
#[test]
fn successive_finds_walk_a_list() {
let src = "genvar i, j;";
let mut scanner = NameScanner::new(src, whole(src));
assert_eq!(scanner.find("i").map(|s| s.start), Some(7));
assert_eq!(scanner.find("j").map(|s| s.start), Some(10));
}
}
+453
View File
@@ -0,0 +1,453 @@
# Type-name spans
## Goal
TODO.md §47 / `docs/topo.md` §2.9-2. `vlog_semantic/src/scan.rs` (193 lines)
recovered the byte range of a name the AST kept only as a `String` by scanning
the construct's own source text. Every declared name got a real `name_span`
from the parser in the 2026-08-19 `name-spans` round; two *uses* did not, and
they were the module's only remaining callers — the type name of a declaration
(`DataType::name`, split as `pkg::item` or `iface.modport`) and `disable
<label>`.
This round puts both spans on the AST, deletes `scan.rs`, and has the binder
read what the parser already knew. A type reference is now located by
construction rather than by a text search that is only right in practice, and
the corpus census pin (`src[name_span] == name`) covers type-name references
for the first time.
## Assumptions
- **A name's span slices back to the name.** `DataType::name_span` is derived
as `name_start .. name_start + name.len()`, so it is exact for every name the
source spells the way the parser joined it. **Any** whitespace or comment
around a `::` or `.` separator (`pkg :: item`, `pkg /* c */ :: item`, a
name split across a line, `bus_if . mp`), an escaped segment terminated by
a newline rather than a space, and spacing inside a dotted `disable` target
spell the name differently from the AST's join (QA's census of the
spellings, 2026-09-05). The binder therefore checks every segment's span
against the source (`Binder::exact_or_empty`) before it records a
reference, which is the rule the modport tail has always followed: such a
segment is recorded with the **empty range at its start** — never a wrong
non-empty range, and never dropped, because an empty range is what the
corpus census counts as *unplaced*, so a parser regression in the join
trips that alarm (lead's rework of QA's MEDIUM). `scan.rs` failed the
same cases (its `find` matches whole words, so it never found `\a+b ` with
its trailing space either), so this is parity, not a new gap.
- **The token text of a plain identifier is its source text.** Pinned by the
lexer (`src[span] == text`, `an_escaped_identifier_ends_before_its_terminating_whitespace`).
Everything above rests on it.
- **`DataType::name_start` is only ever written by the parser.** It is
`pub(crate)` in `vlog_parser`; no other crate builds a `DataType` (grep:
the only `DataType { … }` literals in the workspace are the two in
`vlog_parser/src/parser/`).
- opentitan is read-only. The before/after sweep used the server's scratch
index store (`docs/performance_take3.md` §9) and
`git -C ~/repo/opentitan status --porcelain` reported only the three
pre-existing modified files before and after.
## Handshakes
**Consumed from `vlog_parser`:**
- `DataType::name_span() -> TextRange` — where the type name is written, the
empty range at the would-be position when the type is implicit.
- `DataType::segments() -> impl Iterator<Item = (&str, TextRange)>` — the
`::`/`.`-separated segments with their ranges, derived from `name_span` and
the name's own text. Never rescans the construct.
- `StmtKind::Disable { name, name_span }` — was `Disable(String)`.
**Promised to `vlog_semantic`'s callers:** `analyze(file, src)` keeps its `src`
parameter. It is no longer used to *find* names — nothing in the crate scans
source text any more — but it is still read by `Binder::exact_or_empty`, the
"verify before recording" oracle used by eleven call sites (instance module
names, class `extends` heads and tails, member tails, end labels, the type-name
segments and the `disable` target). Removing it would remove that check, which
is the opposite of what §47 is for. The vlog-semantic README's handshake item 2
("a span for `DataType`") is delivered; the `src` half of item 1's promise
("this parameter goes away") is amended to "src stops being a scanner and
becomes a verifier".
**Not changed, and why:** `lucisv_server/src/type_def.rs` still finds a type
site by a window (`site(&ty.name, TextRange::new(span.start, first))`) rather
than by `DataType::name_span()`. That is a `textDocument/typeDefinition`
concern in another crate and outside §47's file set; it is a clean follow-up
now that the span exists. Filed here rather than edited.
## Status / TODO
- [x] 47.1 `DataType::name_span` at every construction site + `segments()`;
size ruled (below)
- [x] 47.2 `StmtKind::Disable` name span
- [x] 47.3 `scan.rs` deleted, its `mod` removed, binder reads the spans,
census pin now covers type-name references
- [x] Consumers: `nav`/`hover` already go through `Reference::name_span`
(confirmed: `nav.rs` reads only `symbol.name_span` / `reference.name_span`);
two definition tests added
- [x] Gates (guarded)
## The size ruling
`DataType` rides in every `Expr` through `ExprKind::Type`, and `size_pins`
holds `Expr <= 96`. Measured with a throwaway probe test on `v0.44.0`:
| | `DataType` | `ExprKind` | `Expr` | `StmtKind` | `Stmt` |
|---|---|---|---|---|---|
| before | 88 | 88 | 96 | 392 | 552 |
| `pub name_span: TextRange` | 96 | 96 | **104** | **416** | **576** |
| `pub(crate) name_start: u32` | 88 | 88 | 96 | 392 | 552 |
A whole `TextRange` breaks the pin — and `StmtKind`/`Stmt`'s pins with it.
`DataType`'s eight-byte-aligned fields total 80 bytes and `virt` is one more,
so the struct already carries seven bytes of padding: a `u32` fits in it for
free, an eight-byte span does not.
So the span is stored as its **start** and paired with `name.len()` by
`DataType::name_span()`. The plan offered two fallbacks — move the span into
the already-boxed `TypeExtra`, or box it — and this is a third that is better
than both: they would put a heap allocation on *every* `DataType`, because
`name_span` is wanted for the implicit case too (the empty range at the
would-be position), and an implicit type is the common one. The pin did not
move. `name_start` is `pub(crate)`, so the invariant `end == start + len` has
exactly one writer, the parser.
## Construction sites
Five, all in `vlog_parser/src/parser/`:
1. `parse_opt_data_type`'s `sequence`/`property` SVA-formal arm — the keyword
token's start.
2. `parse_opt_data_type`'s `virtual bus_if.mp` arm — delegates to (5).
3. `parse_opt_data_type`'s type-keyword arm (`logic`, `int`, …) — the keyword
token's start.
4. `parse_opt_data_type`'s user-type arm — now calls the existing
`parse_scoped_name`, which already returned the joined text plus the whole
chain's range, so the `::` loop is no longer written twice.
`parse_type_ref` (a bare `my_type_t` where a type is required) calls the
same helper for the same reason.
5. `parse_modport_port_type` — the head identifier's start.
The **implicit** case is spanned by `Parser::implicit_type()`: a `DataType`
whose `name_start` is `self.here()`, the cursor before any of the type has
been consumed. `parse_opt_data_type` starts from it, so an `input [7:0] x`
whose type is nothing at all reports the empty range at the `[`; so does the
`parameter type T` placeholder in `parse_param_decl` and in the parameter-port
list, which write no data type at all. This is the convention `name_span`
already used for an unnamed DPI formal.
## Docs to apply at merge (lead)
Three places in `docs/topo.md`:
- **§2.9 row 2** (line ~618) — struck. Suggested replacement row:
> | ~~2~~ | ~~A span for `DataType` (and `ExprKind::Cast::ty` tails) — the last thing keeping `vlog_semantic/src/scan.rs` alive~~ — **delivered 2026-09-05 by type-name-spans (TODO §47)**: `DataType::name_span()` (stored as a `u32` start paired with `name.len()`, so `Expr` stays inside its 96-byte pin) and `DataType::segments()` (the `::`/`.` split, derived from the span's own text); `StmtKind::Disable` carries its target's span too. `scan.rs` is deleted — nothing in `vlog_semantic` scans source text for a name any more. `analyze`'s `src` parameter stays, no longer as a scanner but as `Binder::exact_or_empty`'s verification oracle. The corpus census pin now covers type-name references. | vlog-semantic (item 2); restated by class-semantics | ~~vlog_parser~~ done |
- **§1.3's `vlog_semantic` layout paragraph** (line ~201) — drop the
`` `scan.rs` (residual text-scanning for the one span the parser doesn't
carry — `DataType`; shrinks to zero when open handshake §2.9-2 lands); ``
clause outright; the file is gone.
- **§1.2's `name-spans ◀──▶ vlog-semantic` row** (line ~449) — the tail
"shrinking `scan.rs` to the `DataType` case (still open — §2.9)" becomes
"…; type-name-spans (§47) delivered the `DataType` case and deleted
`scan.rs`".
- **`crates/vlog_semantic/README.md` does not exist** (the crate has no
top-level README; `docs/features/vlog-semantic/README.md` is the one the
§47 brief means). Its Handshakes/Deviations text was edited in place by this
lane — see the work log.
## Work log
**2026-09-05 — dev agent.**
- Measured the sizes first (throwaway `tests/zz_size_probe.rs`, deleted), which
ruled out the plain `TextRange` field before a line of it was written. See
"The size ruling".
- `DataType` gained `pub(crate) name_start: u32`, `pub fn name_span()` and
`pub fn segments()`, plus a free `separator()` that finds the first `::`/`.`
that is not inside a leading escaped identifier. `segments()` yields nothing
for an implicit type.
- Five parser construction sites set the start; `parse_scoped_name` is now
reused by the two that had open-coded its `::` loop, which is a small
de-duplication that fell out of needing the range.
- `StmtKind::Disable(String)` became `Disable { name, name_span }`. The `fork`
form spans the `fork` keyword; the dotted form spans the whole `a.b` chain.
Formatter (`format/stmt.rs`) and linter (`rules/disable_statement.rs`) match
arms updated; neither reads the span, so no output moves.
- `Binder::bind_data_type` lost its `window` parameter and gained
`bind_type_name`, which walks `ty.segments()` and records the head as a
`Target::Unit` (`::`) or `Target::Type` (`.` or bare) and each following
segment as a member of the one before it. The old code split once and bound
two halves; a three-segment `a::b::c` used to bind `a` plus a `b::c` that no
scan could ever locate, and now binds all three.
- Every span is passed through `exact_or_empty`; a segment that does not
verify was, in the dev's version, the end of the chain (the reference
dropped). **Changed at review:** every segment is recorded, a failing one
with the empty range, so the census's `unplaced` counter — not a quieter
resolution rate — is what a future join regression would move.
Corpus-neutral (`unplaced` was and is 0; no corpus file spells a type name
with spaces around its separators).
- Dropping `window` removed the window computations at ten call sites, and with
them the now-unused `span` parameters of `bind_data_decl`,
`bind_declarators` and `bind_enum_body`.
- `crates/vlog_semantic/src/scan.rs` deleted along with `mod scan;`. Its six
unit tests went with it (they tested the scanner, not a behaviour).
- Tests added: four in `vlog_parser/tests/spans.rs` (a type name slices back to
the name as written across all five sites; `segments()` splits `pkg::state_t`
and `bus_if.mp` and yields nothing for an implicit type; an escaped segment
keeps its terminating space in both the span and the first segment; a
`disable`'s target has a span). The generic statement walker in `spans.rs`
now checks `Disable`'s span instead of skipping the arm. Two in
`lucisv_server/src/nav.rs`: F12 on the item half of `pkg::t` and on both
halves of `bus_if.mp`.
## Gates (all through `tools/guard.sh`; no guard kill)
| gate | result |
|---|---|
| `cargo fmt -p vlog_parser -p vlog_semantic -p vlog_formatter -p vlog_linter -p lucisv_server` | clean |
| `cargo clippy --all-targets` | clean, no new `#[allow]` |
| `cargo test --workspace` | **3 814 passed, 0 failed, 44 ignored** — the 0.44.0 baseline exactly: six `scan.rs` unit tests left, six new ones arrived |
| `tools/corpus_check.sh corpus` | 814/820 (99.3%), the same six parse errors; the per-file TSV is **byte-identical** to the committed `corpus-check-results.tsv` |
| formatter byte-identity | `format --stdout` of all 860 corpus files, new vs `~/.cache/lucisv-baselines/lucisv-0.44.0`: **0 differ** |
| `cargo build --release -p lucisv_server` + smoke | OK — F12 on `pkg::t`'s head and item, on `bus_if.mp`'s head and modport, and on a `disable`'s target all answer the right ranges; hover and `documentSymbol` answer |
| semantic corpus census | 860 files, 27 486 symbols, 103 870 references, 1 197 unresolved, **0 unplaced** — byte-identical to the same test run in a `v0.44.0` scratch worktree |
| opentitan `definition` sweep | 200 type-name positions over 74 files (50 scoped heads, 36 scoped items, 105 bare `_t`/`_e` types, 9 `virtual …_if`), 0.44.0 server vs the new one: **200/200 identical**, 180 of them non-empty answers. opentitan `status --porcelain` reported only the three pre-existing modified files after |
The 0.44.0 baseline binary was built in a scratch `git worktree` at the tag
(`~/.cache/lucisv-baselines/lucisv-0.44.0`, sha256 `4d928238…`, kept for the
next round); the worktree was removed afterwards. Sweep scripts:
`<scratchpad>/defcmp/{lspclient,positions,run}.py`.
### Census: before and after
The plan asked for the new count. The corpus test's numbers are **unchanged in
every field** — 27 486 / 103 870 / 1 197 / 0 unplaced on both sides — which is
the strongest form of the answer: type-name references were already counted,
they were merely located by a scan, and the parser's spans put them in exactly
the same places. (The `21 485` the §47 brief quotes is the 2026-08-19
figure; the corpus and the crate have both grown a great deal since, and the
vlog-semantic README's copy of it has been refreshed to today's numbers.)
## QA log
**2026-09-05 — QA agent.**
Verdict: **PASS**. No hard-invariant violation, no mislocation, no
formatter-output change, no corpus regression. One MEDIUM documentation/
observability finding below; recommend fixing at the lead's discretion
(does not block merge).
### What was verified, and how
1. **Attack battery on `bind_type_name`/`exact_or_empty` (never mislocate).**
Built a scratch integration test
(`crates/vlog_semantic/tests/zz_qa_type_name_spans.rs`, removed before
finishing) exercising `analyze()` over: plain `pkg::item`, spaced
`pkg :: item`, a `/* c */`-interrupted `pkg :: item`, `pkg::` / `item`
split across a line, `\my-pkg ::\state-t` (escaped both sides, space
terminator), `\my-pkg\n::item` (escaped, newline terminator), an escaped
segment whose own text contains `::` (`\a::b ::c`), `bus_if.mp`,
`bus_if . mp` (spaced), `virtual bus_if.mp`, `virtual interface bus_if`
with no modport, `pkg::t` used bare (parameterized-type source next to a
typedef target lacking params — the plain scoped case), an inline `enum`,
an inline `struct`, three implicit-type shapes (`input [7:0] x`,
`parameter type T`, `wire w`), a class-scoped `cls::t`, a cast `int'(x)`,
a scoped cast `pkg::t'(x)`, and five `disable` shapes (`fork`, a plain
label, a dotted `a.b.c`, an escaped label, and a spaced dotted
`a . b . c`).
For every reference `analyze()` recorded across this whole battery,
`src[name_span] == name` held, or the span was empty — **zero
non-empty-but-wrong spans** ("MISMATCH") anywhere. The hard property the
round is built on holds under adversarial input.
**Fallback / dropped-reference count** — spellings where a reference
either fell back to empty or was not recorded at all:
- `\my-pkg\n::item` (escaped, newline-terminated) — **0 references
recorded** (both segments; documented in Assumptions as a known
disagreement).
- `pkg :: item` (spaced) — **`item` not recorded** (only `pkg` is; the
early-return in `bind_type_name` stops at the first segment whose
derived span fails `exact_or_empty`, so everything after it, correct
or not, is silently dropped rather than recorded empty).
- `pkg /* c */ :: item` (comment-interrupted) — same as above, `item`
dropped.
- `pkg::` / `item` split across a line — same, `item` dropped.
- `disable a . b . c` (spaced dotted) — **0 references recorded** (the
whole chain, since `exact_or_empty` checks the joined `a.b.c` against
the real, spaced span as one unit).
- `disable fork` recorded 0 references, but this is pre-existing,
unrelated behavior: `Binder::use_member` filters `is_keyword(name)` and
`fork` is a keyword; confirmed by reading `bind/mod.rs:296-297` and by
the fact the 0.44.0 baseline drops it identically (see below).
No other spelling in the battery fell back to empty or was dropped —
in particular, both escaped-with-space-terminator (`\my-pkg ::\state-t`)
and plain dotted `disable a.b.c` located **exactly**, which is new
(see next point).
2. **0.44.0 baseline comparison (built in a `git worktree` at `v0.44.0`,
removed after).** Ran the identical battery through the old
`scan.rs`-based binder to see what changed, not just what the README
claims:
- **Improvements over 0.44.0** (old code got these wrong, new code gets
them right): `\my-pkg ::\state-t` (old: both halves **empty** — the
scanner's whole-word matcher never includes the escaped segment's
trailing space, so it could never match `push_scope_segment`'s own
join; new: both **exact**). Plain `disable a.b.c` (old: **empty** —
`NameScanner::find` only ever returns single-token words, so a
dotted name can never match as one word; new: **exact**). These are
real, verified accuracy wins from moving off text-scanning.
- **A narrower regression, corpus-neutral in practice**: for
`pkg :: item`, `pkg /* c */ :: item`, and `pkg::`/`item` split across
a line, the **0.44.0 scanner found both `pkg` and `item` at their
correct positions** (whole-word search tokenizes past whitespace and
comments, skipping them — see `scan.rs`'s `next_word`), while the new
code drops `item` entirely once its derived offset (computed from the
tightly-joined `name` string, which does not reflect arbitrary
inter-segment whitespace/comments) no longer covers real source bytes.
This never mislocates — `item` is simply absent from `s.references()`
rather than present with a wrong span — but it is a real loss of
find-and-locate capability for these three SV-legal (if unusual)
spellings, and the old code additionally always recorded *some*
`Reference` (even an empty-span one) where the new code, for the
type-name path specifically, now sometimes records **nothing at all**.
- The `disable`/type-name **modport-tail** shapes (`bus_if.mp`,
`bus_if . mp` spaced) are **byte-for-byte identical** old vs new,
confirming the modport tail's own pre-existing "skip if empty"
convention was carried over unchanged, as the work log claims.
Finding (**MEDIUM**, doc/observability, not a correctness bug): the
README's Assumptions section names only two "joins that can disagree"
(an escaped segment's space, and the modport `.`). Empirically, *any*
whitespace or comment between `::`-separated segments, and any spacing
in a dotted `disable` target, also disagrees and silently drops the
affected reference — and, specific to the binder's new early-return in
`bind_type_name` (`crates/vlog_semantic/src/bind/decl.rs`), a segment
past the first divergence is not merely mislocated-and-caught but never
recorded as a `Reference` at all (0.44.0 always recorded one, with an
empty span, via `NameScanner`'s always-recording callers). This means a
future regression in the parser's own joining logic for these
constructs would no longer surface as `unplaced > 0` in the corpus
census (`crates/vlog_semantic/tests/corpus.rs`'s `covers()` only counts
spans that exist; a dropped reference contributes nothing) — it would
have to be caught by resolution-rate drift instead, which is a weaker
signal. Recommend the Assumptions section name the fuller set of
disagreeing spellings (whitespace/comments around any `::`/`.`, not
only the escaped-segment case), and/or that `bind_type_name` record a
trailing empty-span reference on early return the way the pre-round
code did, so the census keeps its loud-failure property. Not a merge
blocker: corpus-neutral (verified below), never mislocates, and the
`disable`/type-name-with-whitespace spellings are rare in real RTL.
3. **Census pin.** `tools/guard.sh -- cargo test -p vlog_semantic --test
corpus -- --nocapture`: **860 files, 27 486 symbols, 103 870
references, 1 197 unresolved (1.15%), 0 unplaced** — matches the
README's claim exactly (re-derived independently, not read off the
README). Confirmed `covers()` (`tests/corpus.rs:69-80`) asserts
`src[span] == name` for every non-empty-span reference and symbol
uniformly (not type-references-only, but type references are now part
of that population for the first time, per the round's stated purpose)
and that an empty span is counted as "unplaced" rather than exempted —
so the 0-unplaced result is a real assertion, not a vacuous one, over
the actual corpus.
4. **`disable` spans + formatter/linter round-trip.** Confirmed via the
parser's own new tests (`a_disable_names_its_target_with_a_span`,
`spans.rs`) and independently via `lucisv format --stdout` /
`lucisv check` on a hand-written `fork`/label/dotted-label file: output
is idempotent (`format(format(x)) == format(x)`) and byte-identical to
the `lucisv-0.44.0` baseline binary, and `lucisv check`'s
`disable-statement` diagnostic is identical old vs new. Confirms the
formatter/linter genuinely ignore the new span (as the work log
claims) — output moved nowhere.
5. **Size pins.** `tools/guard.sh -- cargo test -p vlog_parser --lib
size_pins`: `expr_stmt_and_stmt_kind_stay_within_their_pinned_sizes`
passes (`Expr <= 96`, `StmtKind <= 392`, `Stmt <= 552`), confirming the
`name_start: u32` design keeps every pin where §36's protocol left it.
6. **Server: definition/hover/typeDefinition/rename, in-tree and over
opentitan.**
- `cargo test -p lucisv_server`: the dev's two new `nav.rs` tests pass
(`a_scoped_type_name_jumps_from_its_item_half`,
`an_interface_port_type_jumps_from_its_head`), as part of the full
3 814-test run below.
- Added a temporary `#[test]` in `crates/lucisv_server/src/rename.rs`
(removed before finishing; `git diff` on that file is empty now) that
renames a package typedef `t` used as `pkg::t` from three files.
Result: **all three files edited, each edit's range slicing to
exactly `t`** (verified by slicing the edit's own `TextEdit.range`
out of the source line) — never `pkg::t`, confirming attack item 4's
rename requirement directly rather than by inspection.
- `lucisv_server/src/type_def.rs` is untouched by this round (confirmed
by `git diff --stat`) and still locates a type site by its own
from-scratch window/`site()` walk, independent of
`DataType::name_span`/`segments()` — exactly what the Handshakes
section says. Verified it still answers correctly (see next point),
so the "clean follow-up, not a regression" framing holds.
- **Opentitan sweep, independently re-derived** (attack item 5): wrote
a second position-picker (`<scratchpad>/defcmp/qa_positions.py`)
targeting a **disjoint set of directories** from the dev's own script
(`hw/ip/otp_ctrl/rtl`, `hw/ip/flash_ctrl/rtl`, `hw/ip/i2c/rtl`,
`hw/ip/rv_dm/rtl`, `hw/ip/spi_host/rtl`, `hw/dv/sv/tl_agent`,
`hw/dv/sv/csr_utils` — the dev used `aes`/`hmac`/`spi_device`/`uart`/
`uart_agent`/`cip_lib`/`dv_lib`), picking 200 positions over 43
files. Built the 0.44.0 `lucisv-server` in the same `v0.44.0`
worktree used for the binder comparison, and ran both
`textDocument/definition`, `textDocument/hover`, and
`textDocument/typeDefinition` over all 200 positions with both
servers (`<scratchpad>/defcmp/run.py`, `run_hover_typedef.py` — the
latter is a QA-added twin of the dev's `run.py` adding hover/
typeDefinition, since the original only asked `definition`).
Results: **definition 200/200 identical (149 non-empty)**, **hover
200/200 identical (149 non-empty)**, **typeDefinition 200/200
identical (63 non-empty)**. `git -C ~/repo/opentitan status
--porcelain` reported only the three pre-existing modified files
after every run (before, during, and after — checked three times).
### Gates re-run independently (all guarded, all matched the dev's numbers)
| gate | result |
|---|---|
| `cargo clippy --all-targets` | clean (fully cached; 0 warnings/errors) |
| `tools/guard.sh -- cargo test --workspace` | **3 814 passed** (3 815 with my scratch test counted, subtracted), **0 failed, 44 ignored** — exact match |
| `tools/guard.sh -- tools/corpus_check.sh corpus` | 814/820 (99.3%), same six parse errors, 0 verification errors, 0 crashes; `git diff --stat -- corpus-check-results.tsv` empty (byte-identical) |
| formatter byte-identity | wrote an independent diff script; `lucisv format --stdout` on all 860 corpus files vs `~/.cache/lucisv-baselines/lucisv-0.44.0`: **0 differ** |
| census | 860 files / 27 486 symbols / 103 870 references / 1 197 unresolved / **0 unplaced** — re-derived, not copied |
| opentitan definition/hover/typeDefinition sweep | 200/200/200 identical old vs new on an independently-chosen position set; opentitan `status --porcelain` clean (only the three pre-existing files) throughout |
No guard kill anywhere.
### Cleanup
Removed: `crates/vlog_semantic/tests/zz_qa_type_name_spans.rs` (scratch
test), the temporary `#[test]` in `crates/lucisv_server/src/rename.rs`
(confirmed `git diff` on that file is now empty), the `v0.44.0` scratch
`git worktree` (`git worktree remove`, confirmed gone from
`git worktree list`), and both scratch server storage directories. Left
in the scratchpad (not the repo) for the lead's reference:
`<scratchpad>/defcmp/qa_positions.py`, `qa_positions.json`,
`qa_old.json`/`qa_new.json` (definition), `qa_old_ht.json`/`qa_new_ht.json`
(hover/typeDefinition), `run_hover_typedef.py`, `byte_identity_check.sh`.
## Review
## Review
**2026-09-05 — lead.** Accepted with one rework; ships in 0.45.0 with §48
and §49. The size ruling is the right one: a `u32` start in the padding
`DataType` already had keeps `Expr` at 96 with no allocation on the common
implicit case, and the derived end is verified against the source before
any reference is recorded, so the "never mislocate" invariant held under
QA's whole battery. QA's MEDIUM was fair — a dropped reference silences the
census alarm the pin exists for — and is fixed by recording the empty-range
placeholder instead of returning early; the README's list of disagreeing
spellings is now the full one QA found. Two shapes the old scanner always
failed (an escaped segment with a space terminator, a dotted `disable`
target) are now exact. Census unchanged in every field, 0 of 860 corpus
files differ, 200/200 opentitan answers identical for definition, hover and
typeDefinition. The `type_def.rs` window lookup is filed as a follow-up in
Handshakes, not a regression.
+46 -14
View File
@@ -62,16 +62,23 @@ enum Resolution {
### Deviations from the sketch in the task, and why
- **`analyze` takes `src` as well as the tree.** Most declarations in the AST
keep their name as a plain `String` and carry a span only for the whole
construct, so the *name's* range — the thing an editor highlights — is not
recoverable from the tree alone. `scan.rs` finds it by scanning the
construct's own source bytes (comments, strings and macro invocations
skipped) inside a window narrowed by the sub-spans that *do* exist. The
corpus test asserts `src[name_span] == name` for all 21 485 symbols and
73 708 references it builds, so the scan is not a guess in practice. A
Handshake request to put `name_span` on the AST is filed below; when it
lands, `scan.rs` and this parameter go away.
- **`analyze` takes `src` as well as the tree.** Originally because most
declarations kept their name as a plain `String` inside a construct-wide
span, so the *name's* range — the thing an editor highlights — was not
recoverable from the tree at all; `scan.rs` found it by scanning the
construct's own source bytes inside a window narrowed by the sub-spans that
did exist. **Both halves of that are gone**: `name-spans` (2026-08-19) put
`name_span` on every declaring node, `type-name-spans` (2026-09-05, TODO
§47) put `DataType::name_span()`/`segments()` and `StmtKind::Disable`'s span
on the last two, and `scan.rs` is deleted. `src` stays, in a different
role: `Binder::exact_or_empty` checks a derived span against the source
before a reference is recorded, so a name the source spells differently from
the way the parser joined it (`bus_if . mp` written apart, an escaped
segment terminated by a newline) costs the reference rather than
mislocating it. Eleven call sites rely on that oracle. The corpus test still
asserts `src[name_span] == name` for every symbol and reference it builds —
27 486 and 103 870 as of 2026-09-05, type-name references now among them,
0 unplaced.
- **`Reference.resolution: Resolution` instead of `resolved:
Option<SymbolId>`.** The task asked for both an `Option<SymbolId>` and an
`ExternalCandidate` state carrying the import path; one enum says that once.
@@ -280,15 +287,21 @@ region | generate block | for-generate header | for/foreach statement`.
- `src` passed to `analyze` is the exact text the tree was parsed from. Spans
index into it; a mismatched string yields wrong name spans, not a panic
(every slice is bounds-checked and clamped).
- A construct's keyword is written before its name (`module m`, `function
- ~~A construct's keyword is written before its name (`module m`, `function
automatic int f`), and the name is a plain identifier. Where a type name and
the declared name are the same token text (`function foo_t foo_t;`) the scan
can pick the first of the two; nothing in the corpus does this.
can pick the first of the two; nothing in the corpus does this.~~ Retired
2026-09-05 by `type-name-spans`: nothing here scans for a name any more, so
no assumption about where one is written is left to make.
- The parser bounds nesting depth (`MAX_NESTING_DEPTH`, TODO.md §1), so the
recursive walk here inherits a bounded stack and needs no depth counter of
its own.
- Identifiers are ASCII in practice; the scanner treats non-ASCII bytes as
non-identifier bytes and never slices inside a multi-byte character.
- A span derived rather than received is checked against the source before it
becomes a reference (`Binder::exact_or_empty`). What is derived is small and
named: a `Member`/`Scope` tail, a class `extends` head and tail, an instance
module name, an end label, the `::`/`.` segments of a type name, and a
`disable` target. Anything that does not slice back to the name costs the
reference; nothing is ever recorded at a guessed position.
## Handshakes
@@ -332,6 +345,11 @@ feature, and the crate works without it):
`docs/features/name-spans/README.md`.
2. **A span for `DataType`** (and for `ExprKind::Cast::ty`), so a type
reference does not need a window computed from its neighbours' spans.
**Delivered 2026-09-05 by `type-name-spans`** (TODO §47) — `DataType`
carries `name_span()` and `segments()`, `StmtKind::Disable` carries its
target's span, `bind_data_type` lost its `window` parameter, and
`crates/vlog_semantic/src/scan.rs` is deleted; see
`docs/features/type-name-spans/README.md`.
3. Nice to have, much smaller: the byte range of `Member`/`Scope` tails, which
is today derived as `span.end - name.len()`.
@@ -433,6 +451,20 @@ anywhere, and under 3 % unresolved on cleanly-parsed files.
## Work log
**2026-09-05 — type-name-spans (TODO.md §47).** `scan.rs` deleted, `mod scan;`
with it: the parser now carries `DataType::name_span()` /
`DataType::segments()` and `StmtKind::Disable`'s span, so the two remaining
scan callers read them instead. `bind_data_type` lost its `window` parameter
(and with it the window computations at ten call sites, plus the now-unused
`span` parameters of `bind_data_decl`, `bind_declarators` and
`bind_enum_body`) and gained `bind_type_name`, which walks the segments and
records the head as `Target::Unit`/`Target::Type` and each following segment
as a member of the one before it — so a three-segment `a::b::c`, which used to
bind an unlocatable `b::c`, binds all three. Every segment goes through
`exact_or_empty` first. Corpus census byte-identical before and after: 860
files, 27 486 symbols, 103 870 references, 1 197 unresolved, 0 unplaced.
Details in `docs/features/type-name-spans/README.md`.
**2026-08-27 — indexed navigation.** `Semantics` now builds compact sorted
`(TextRange, SymbolId/ReferenceId)` position tables with the analysis.
`symbol_at`, `reference_at` and `reference_id_at` binary-search those tables;
+2 -4
View File
@@ -198,8 +198,6 @@ an error means emit nothing.
`stmt`, `sva`, `expr`) →
`model.rs`; `resolve.rs` (the lexical walk; misses become
`ExternalCandidate`/`InheritedCandidate` carrying candidate paths);
`scan.rs` (residual text-scanning for the one span the parser doesn't carry —
`DataType`; shrinks to zero when open handshake §2.9-2 lands);
`workspace/` (`mod` = the tables, `index` = queries and `build`, `update` =
incremental update and `fingerprint`, `record` = the `FileFacts` read-off,
`external` = the overlay; `WorkspaceIndex`: units, members, defines, instantiation and
@@ -446,7 +444,7 @@ recursion-limit, whose edges sit in §2.1). Code edges:
| `formatter-bug-fixes (round 2) ──▶ safety-net` | depends | Three comment-shape bugs fixed in `format.rs` (`then_is_block` trailing-line-comment cuddle guard, `Fmt::header_parens`, `default_has_colon`); `verify.rs` untouched, four masked-corruption rejection pairs added per the standing template, plus three more for the directive capture at merge (2026-08-29 testbench wave, Lane B + lead). |
| `lexer-cleanup ──▶ error-recovery / lint-rules-2` (QA logs) | depends | Fixes three lexer gaps: `@(* )` (TODO §1) plus the BOM and non-ASCII-honesty findings those two QA rounds filed; adds `ParsedSource::lex_error()` so `lucisv check` stops silently passing unlexable files. |
| `error-recovery ─▶ lucisv-server / linter-core` | depends (downstream) | `parse_source_tolerant` is the entry point the whole LSP and the linter stand on; the strict/tolerant split (shared grammar, no second parser) is the contract. |
| `name-spans ◀──▶ vlog-semantic` | handshake | vlog-semantic filed request 1 (spans on ~15 declaring nodes); name-spans delivered it, shrinking `scan.rs` to the `DataType` case (still open — §2.9). |
| `name-spans ◀──▶ vlog-semantic` | handshake | vlog-semantic filed request 1 (spans on ~15 declaring nodes); name-spans delivered it, shrinking `scan.rs` to the `DataType` case; type-name-spans (§47, 2026-09-05) delivered the `DataType` case and deleted `scan.rs`. |
| `spans ─▶ everything positional` | depends | Byte ranges + `LineIndex` are the prerequisite named by TODO §6 for the LSP effort and by fences/range formatting. |
Also uniform in this lane: each new AST variant lists its exhaustive-match
@@ -615,7 +613,7 @@ update the filing README(s) and this file.
| # | request | filed by | owner it waits on |
|---|---|---|---|
| 1 | `lucisv_core::path::normalize` — one `.`/`..` folding instead of three private copies (`filelist::Reader::normalize`, `config::Discovery::absolute`, `includes::normalize`, the last now `pub`) | include-nav; restated by file-operations | lucisv_core |
| 2 | A span for `DataType` (and `ExprKind::Cast::ty` tails) — the last thing keeping `vlog_semantic/src/scan.rs` alive | vlog-semantic (item 2); restated by class-semantics | vlog_parser |
| ~~2~~ | ~~A span for `DataType` (and `ExprKind::Cast::ty` tails) — the last thing keeping `vlog_semantic/src/scan.rs` alive~~ — **delivered 2026-09-05 by type-name-spans (TODO §47):** `DataType::name_span()` (a `u32` start paired with `name.len()`, so `Expr` stays inside its 96-byte pin) and `DataType::segments()` (the `::`/`.` split from the span's own text); `StmtKind::Disable` carries its target's span. `scan.rs` is deleted; `analyze`'s `src` stays as `Binder::exact_or_empty`'s verification oracle — a segment whose derived range does not read back is recorded with the empty range (counted *unplaced* by the census, never dropped). The census pin covers type-name references. | vlog-semantic (item 2); restated by class-semantics | vlog_parser |
| ~~3~~ | ~~`fence::scan_nested` has no `ItemKind::Class` arm — formatter fences are inert inside class bodies (the `--fix` backstop still holds; asymmetry errs hands-off)~~ — **delivered 2026-09-02 by statement-fences (TODO §31)**: `scan_nested` enters class bodies, functions, tasks, `always`/`initial`/`final`; statement lists (`begin…end`, `fork…join`, every compound body) are fenceable through `scan_stmt_scope`/`scan_nested_stmt` on the shared `scan_units`; `stmt_docs`/`stmt_seq` obey the two swallowed-unit rules; fence regions merge into `range.rs`'s plan (load-bearing — a fenced statement has no verbatim run behind it). A region opens only at a line start (`opens_line`), so `module m; // lucisv: off` no longer opens one — the rule the format-fences README has stated since round 1. Deferred with reasons: port lists, case-item label lists, same-line fences, `PropSeqDecl.locals`. Opentitan: 4 of its 9 fenced files now keep their fenced bytes. | classes | ~~vlog_formatter (fence.rs)~~ done |
| ~~4~~ | ~~A `lint` key in `lucisv.toml` (`[lint.<rule>]` config; selected-rules list) with CLI>config precedence~~ — **delivered 2026-09-02 by semantic-lints-on**: `[lint] select = […] / ignore = […]` in `lucisv.toml` (CLI over config, key by key; unknown rule names fail the run naming the file; `[lint.<rule>]` tables rejected by name — per-rule config was delivered later by linter-expansion-2, v0.38.0; the earlier rejection described here is historical) and `lucisv.lint.select/ignore` settings (registry-validated, republish on change). | linter-core; restated by lint-rules-2, semantic-lints, server-lint | ~~config-discovery / lucisv_core~~ done |
| ~~5~~ | ~~`lucisv check --rules-doc` printing `rules_markdown()`~~ — **delivered 2026-09-02 by macro-word-census (TODO §29.3)**: `lucisv check --rules-doc` prints `rules_markdown()` and exits 0, takes no files, is lint-only; the example binary is gone | lint-rules-2 | ~~crates/lucisv~~ done |