Struct members: s.field, reg2hw.ctrl.q and the anonymous aggregates resolve
coverage_gaps H1 + topo 2.9-13 delivered. The in-file gap was one resolver gate: member_scope now returns any symbol's child scope when it is a Struct scope, so a typedef, an anonymous struct declarator and an inline nested field are one rule; fields declare with their own type so s.hdr.addr hops through a member. Cross-file, struct members export under the typedef's name, package-nested struct typedefs under their bare name (the nested-class convention, ambiguity refused), and inline nested fields - the opentitan register-package shape - under a synthesized owner.field key carried as the field's type: joined with '.', not '::', because member_type's last_segment would collapse the latter to the bare field name and q/d/qe live in every register package. Anonymous enum variants land in the enclosing scope like typedef ones. FACTS_FORMAT 8 -> 9; typeDefinition descends into typedef struct bodies. Unresolved fell 1203 -> 1162; the corpus store shrank 1.1 percent (resolved locals encode smaller than the candidates they replaced), opentitan's register packages grow it 4.3 percent. QA: 28 opentitan probes, three planted sibling pairs (rxfull/fmtfull, avsetup_rst/ avout_rst, tpm_csb/csb) all correct, zero wrong answers, hover under 0.5 ms. docs/features/struct-members/README.md; TODO.md section 17. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
95f930cf20
commit
2a2334ef5a
14 files changed
+1800
-85
No files matched your search
@@ -84,6 +84,10 @@ answer is the only forbidden outcome.**
|
||||
declaration all name no type at all, so they stay exactly what they were:
|
||||
nothing recorded. The walk is visited-guarded, so `typedef a_t b_t;
|
||||
typedef b_t a_t;` terminates.
|
||||
**Amended 2026-09-01 by struct-members**: a `typedef struct` no longer needs
|
||||
following — it *is* the type, and it now opens a scope of its own, which is
|
||||
what makes `typedef s_t alias_t; alias_t s; s.field` land through this very
|
||||
same alias chase. The other three are unchanged and still record nothing.
|
||||
- **Only `Ident` heads** — *amended by round 2*. A chain of `.`-separated
|
||||
identifiers is walked whole (`a.b.c.d`), and an instance name is a head like
|
||||
any other because its declared type is its module. Still head-only: an
|
||||
@@ -483,6 +487,11 @@ symbol to take a type from, and inventing one is a model change. An indexed or
|
||||
called link (`q[i].x`, `f().x`) is unchanged. A cross-file alias is followed
|
||||
only for a **file-scope** typedef (`index.units`); a typedef inside a package
|
||||
is a member, not a unit, and is not chased — filed, not attempted.
|
||||
**Note added 2026-09-01 by struct-members**: the package-nested case is now
|
||||
covered for *aggregates* by a different route — `collect_members` recurses into
|
||||
a package's struct typedef and registers its fields under the typedef's bare
|
||||
name — so `pkg::bus_t s; s.field` lands. A package-nested **alias** of a class
|
||||
(`package p; typedef c1 my_t;`) is still not chased; unchanged, still filed.
|
||||
|
||||
**Pins rewritten in place, all four because the round changes what is true:**
|
||||
`semantics.rs::a_hierarchical_name_resolves_only_its_head` →
|
||||
|
||||
@@ -0,0 +1,534 @@
|
||||
# struct-members
|
||||
|
||||
## Goal
|
||||
|
||||
`typedef struct packed { logic [7:0] addr; } bus_t; bus_t s; s.addr` recorded
|
||||
nothing at all before this round: hovering `addr` showed nothing, F12 did
|
||||
nothing, and renaming the field left every use behind. Struct and union fields
|
||||
are how RTL is written — a generated register package (`reg2hw.ctrl.q`), a
|
||||
bus payload (`tl_i.a_address`), a DV config bundle — so the single largest
|
||||
class of daily-driver names in a Verilog workspace was invisible. This round
|
||||
gives a `struct`/`union` body the same standing every other named container
|
||||
already has: its fields are **declarations** with their own declared types,
|
||||
`resolve.rs` looks a member access up in them in-file, and the workspace index
|
||||
exports them so `pkg::bus_t s; s.addr` crosses a file boundary. It also
|
||||
delivers topo §2.9-13, the three **anonymous** forms that had no symbols at
|
||||
all: `enum {A,B} x;`, `struct {…} s;`, and the inline nested member
|
||||
(`struct packed { struct packed { logic q; } ctrl; } reg2hw_t;`) that every
|
||||
generated register package is made of.
|
||||
|
||||
The governing rule is class-member-access's, unchanged and load-bearing for
|
||||
every stopping condition below: **a link that cannot be resolved honestly
|
||||
records nothing, and nothing after it — a wrong answer is the only forbidden
|
||||
outcome.**
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **A struct body is a scope, and its fields are its members.** The binder
|
||||
already opened a `ScopeKind::Struct` scope on the typedef symbol and declared
|
||||
each field into it; nothing looked in. What changes is who may look: a `.`
|
||||
through a value of that type, and the workspace's member table. Nothing else
|
||||
searches a struct scope — name lookup still never walks into one, because no
|
||||
pending use is ever recorded *in* one (a field's type, dimensions and
|
||||
initializer are all bound in the scope the body is **written** in, which is
|
||||
where those names are looked up from).
|
||||
- **`union` is `struct`.** One AST node (`StructType::kw`), one scope kind, one
|
||||
set of rules. A union's fields overlap in storage, which is a fact about
|
||||
elaboration and not about which names a `.` may write.
|
||||
- **A field carries its declared type, on the same terms every other
|
||||
declarator does** — including the unpacked rule: `logic [7:0] arr [4]` names
|
||||
a container, so no `type_name`, so `s.arr.anything` records nothing rather
|
||||
than pretending the element's type is the array's.
|
||||
- **A field genuinely absent from a struct records nothing.** The body is
|
||||
written here whole; no other file can supply a field, so there is nothing to
|
||||
ask the workspace and `NotFound` would overstate what is known. Same rule as
|
||||
a fully-known class with no base.
|
||||
- **An enum typedef head still records nothing.** `state_e st; st.name()` is a
|
||||
built-in method (IEEE 1800 §6.19.5), not a member of anything this crate
|
||||
models, and inventing an answer for it would be the forbidden outcome. So
|
||||
would an alias of a built-in (`typedef int alias_t; v.whatever`). Both pins
|
||||
from round 1 stay exactly as written.
|
||||
- **An anonymous aggregate's members hang off the declarator that names it.**
|
||||
`struct packed { logic a; } s;` has no type name for `s.a` to be looked up
|
||||
through, so `s`'s own symbol opens the `Struct` scope and `resolve.rs`
|
||||
reaches it through the same "this symbol opens a body" rule. This is
|
||||
**in-file only**: no other file can name this variable's type, because it has
|
||||
none, so `pkg::cfg.f` from another file stays unresolved. Stated, not
|
||||
worked around.
|
||||
- **An inline nested member is reached in-file by its own scope and across
|
||||
files by a synthesized key.** `struct packed { struct packed { logic q; }
|
||||
ctrl; } reg2hw_t;` gives `ctrl` a scope of its own in-file. Across files the
|
||||
index registers the inner fields under `reg2hw_t.ctrl` — the container's key
|
||||
and the member's name joined by a **`.`** — and puts that same spelling on
|
||||
`ctrl`'s own `Def::type_name`, so the existing `member_type` hop walks
|
||||
`reg2hw_t` → `ctrl` → `reg2hw_t.ctrl` → `q` with no new mechanism. Two
|
||||
properties earn the `.`: no source can write it as a type name (the one
|
||||
dotted spelling SystemVerilog has, `bus_if.mp`, is stripped to the interface
|
||||
half before it is ever recorded), so a synthesized key can never collide with
|
||||
a real unit or typedef; and it survives `last_segment` whole, which the
|
||||
brief's `::` spelling would not. The bare alternative is unusable: `q`, `d`
|
||||
and `qe` are the field names *every* generated register package repeats.
|
||||
- **A struct typedef nested in a package exports under its bare name**, exactly
|
||||
as a class nested in a package already does — which is what makes
|
||||
`pkg::bus_t s; s.addr` land, because `resolve.rs` composes the path from the
|
||||
type name's **last segment**. The cost is stated rather than solved: two
|
||||
packages each declaring `typedef struct {…} cfg_t` collide in the member
|
||||
table under `cfg_t`, and the lookup then answers `Ambiguous` (every
|
||||
candidate, never a guess) or, for a *hop* through such a name, nothing at
|
||||
all. That is the crate-wide duplicate-name policy, not a new one.
|
||||
- **A type name the workspace declares twice still refuses the hop.** A struct
|
||||
`hdr_t` in one file and an unrelated class `hdr_t` in another are two
|
||||
answers, and `member_type` picks between candidates nowhere. This round makes
|
||||
the struct half *able* to answer, which makes the refusal matter more, not
|
||||
less.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**Consumed from `vlog_parser`** (no change requested):
|
||||
`TypedefKind::Struct(StructType)`, `StructType::members`,
|
||||
`StructMember::{ty, declarators}`, `Declarator::{name, name_span, unpacked}`,
|
||||
`DataType::inline() -> Option<&TypeExtra>` and `TypeExtra::{Enum, Struct}` —
|
||||
the last two are what make an anonymous or inline aggregate reachable at all.
|
||||
Handshake item 2 (a span for `DataType`) stays open and untouched.
|
||||
|
||||
**Changed in `vlog_semantic` (this crate), all additive:**
|
||||
|
||||
1. `bind.rs::bind_struct_members` declares a body's fields with
|
||||
`declare_typed` (they carried no type before), and gives a field whose type
|
||||
is an **inline nested** aggregate a `ScopeKind::Struct` child scope of its
|
||||
own, recursively to any depth.
|
||||
2. `bind.rs::bind_struct_uses` records every *use* written inside a body — a
|
||||
field's type name, its dimensions, its initializer — in the scope the body
|
||||
is written in. Split from the declaration half so a body written once and
|
||||
declared under several declarators (`struct { hdr_t h; } a, b;`) records its
|
||||
type names **once**. The pending-use order is byte-for-byte what it was,
|
||||
because declarations record no pendings.
|
||||
3. `bind.rs::bind_enum_body` is the one function all three enum spellings go
|
||||
through — `typedef enum`, an anonymous `enum {A,B} x;`, and an anonymous
|
||||
enum standing as a struct field's type. Its members are declared in the
|
||||
scope **holding** the enum (IEEE 1800 §6.19), which is what `typedef enum`
|
||||
already did and what the anonymous form now does too.
|
||||
4. `bind.rs::bind_data_type` descends into an inline aggregate (`ty.inline()`)
|
||||
for its uses, and `bind_declarators` gives an anonymous `struct {…} s;`
|
||||
declarator its own `Struct` scope.
|
||||
5. `resolve.rs::member_scope` accepts **any symbol whose child scope is a
|
||||
`Struct` scope**, not only a class/module/interface. One rule serves the
|
||||
typedef that names a body, the declarator of an anonymous one, and an
|
||||
inline nested member — three shapes, no special cases. `type_here`'s alias
|
||||
chase and `link_type`'s "a head with no type name may still open a scope"
|
||||
arm both reach it unchanged.
|
||||
6. `workspace.rs::is_exported` gains a `Typedef | StructMember` arm exporting
|
||||
`StructMember`, and `collect_members` takes the member-table **key**
|
||||
explicitly so it can recurse into a struct typedef nested in a package
|
||||
(under the typedef's bare name, the nested-class convention) and into an
|
||||
inline nested member (under the synthesized key from `nested_key`).
|
||||
7. `FACTS_FORMAT` 8 → 9: the member census and the reference census both grow.
|
||||
|
||||
**Promised to consumers:** `analyze` still never panics; every recorded
|
||||
`name_span` still slices back to exactly the name; the `paths` spelling
|
||||
contract is unchanged and `follow_one` reads it exactly as before — the only
|
||||
new spelling is a synthesized `Def::type_name`, which is consumed by
|
||||
`member_type` alone and is unwritable in source.
|
||||
|
||||
**Requested of `lucisv_server`, and delivered inside this lane's own file
|
||||
list:** `type_def.rs::alias_site` descends into a `typedef struct` body so
|
||||
`textDocument/typeDefinition` answers on a field's type name and on the
|
||||
field's own declarator. `index_cache.rs` needed no change: 8 → 9 alters the
|
||||
census, not the record layout, so `as_a_format_4_record` strips exactly the
|
||||
fields it stripped before.
|
||||
|
||||
**Filed, not done (for the lead):**
|
||||
|
||||
- **Member completion after `.`** — the follow-on lane TODO.md §17 already
|
||||
names. `completion.rs` has no dot context at all today, and now that
|
||||
`reg2hw.` has members to list, that is the natural next daily driver. Not
|
||||
this lane's file.
|
||||
- **`typeDefinition` inside an anonymous aggregate written as a data
|
||||
declaration** (`struct { hdr_t h; } s;`, as opposed to a `typedef struct`).
|
||||
`declarator_site` would have to take the cursor offset, which means touching
|
||||
every one of its eight call sites for a shape the brief did not ask for.
|
||||
Filed rather than done.
|
||||
- **Cross-file anonymous struct variables** (`pkg::cfg.f` where `cfg` is a
|
||||
package-level `struct {…} cfg;`). The variable's type has no name, so the
|
||||
member table has nothing to key on; a synthesized key would have to be
|
||||
minted for a *variable*, which is a different decision from minting one for
|
||||
an inline member of a named type. In-file resolution works.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] In-file: `member_scope` accepts a `Struct` child scope; fields declared
|
||||
with `declare_typed`; an alias of a struct follows to it; enum and
|
||||
int-alias heads still record nothing.
|
||||
- [x] Cross-file: `is_exported(Typedef|StructMember, StructMember)`;
|
||||
`collect_members` keyed and recursive; `Def::type_name` on fields.
|
||||
- [x] Anonymous forms: `enum {A,B} x;` variants; anonymous `struct {…} s;`
|
||||
child scope; inline nested members in-file and, across files, under the
|
||||
synthesized `owner.field` key.
|
||||
- [x] `FACTS_FORMAT` 8 → 9.
|
||||
- [x] `type_def.rs`: descent into a `typedef struct` body.
|
||||
- [x] Pins flipped and kept — see the work log.
|
||||
- [x] Tests: new `crates/vlog_semantic/tests/struct_members.rs`, flips in
|
||||
`member_access.rs`, e2e in `crates/lucisv_server/tests/e2e.rs`.
|
||||
- [x] Corpus acceptance and store delta.
|
||||
|
||||
## Corpus acceptance and cost
|
||||
|
||||
`cargo test -p vlog_semantic --test corpus -- --nocapture`, plus the
|
||||
`#[ignore]`d probe `what_the_tail_references_cost_the_index` in
|
||||
`tests/member_access.rs`. "Before" was measured in a detached worktree at this
|
||||
round's trunk (`95f930c`, v0.24.0) with the same corpus symlinked in, so both
|
||||
columns are the same 860 files on the same machine.
|
||||
|
||||
| 860-file corpus | before (`95f930c`) | after |
|
||||
|---|---:|---:|
|
||||
| symbols | 26 844 | **26 953** (+109) |
|
||||
| references | 99 237 | **99 553** (+316) |
|
||||
| resolved in-file | 70.3 % | 70.4 % |
|
||||
| external candidates | 20.6 % | 20.5 % |
|
||||
| inherited candidates | 7.9 % | 7.9 % |
|
||||
| **unresolved** | 1 203 (1.21 %) | **1 162** (1.17 %) |
|
||||
| names unplaced | 0 | **0** |
|
||||
| indexed members | 12 298 | **12 642** (+344) |
|
||||
| store bytes (`FileFacts::encode`, all 860 records) | 3 216 689 | **3 179 905** |
|
||||
| time to read all 860 records | 1.004 s | 1.005 s |
|
||||
|
||||
**The store got 36 784 bytes *smaller* (−1.14 %) while gaining 344 indexed
|
||||
members**, which is worth stating plainly because it is the opposite of what a
|
||||
round that exports more declarations should cost. The reason is the anonymous
|
||||
forms: a bare use of an `enum {A, B} x;` variant used to be an
|
||||
`ExternalCandidate` (or an `InheritedCandidate`) carrying its name and every
|
||||
import path in scope, and is now `Resolved` — encoded as a `Local` fact, two
|
||||
ranges and nothing else. Converting a few hundred of those buys back more than
|
||||
the new `M` entries cost on this corpus. **The corpus is not the whole story**:
|
||||
it holds 22 file-scope typedefs and no generated register packages, so a real
|
||||
RTL tree with `*_reg_pkg.sv` files will grow instead. QA's opentitan pass is
|
||||
where that number comes from; it is expected to be a *gain*, and the read path
|
||||
is unchanged either way.
|
||||
|
||||
**Unresolved falls by 41 and unplaced stays at 0.** That is the acceptance
|
||||
column that matters: the round added 316 references and not one of them is a
|
||||
name that resolves to nothing — every new tail either lands on a declaration or
|
||||
was never recorded — and it *removed* 41 names that used to resolve to nothing,
|
||||
which is exactly the anonymous-enum variants finally having declarations.
|
||||
|
||||
**What a lookup costs.** Nothing new on the hot path. In-file, `member_scope`
|
||||
gains one scope-kind comparison; the walk is the same `lookup_local` it always
|
||||
was. Across files, a struct hop is the same `member_chain` map read a class hop
|
||||
is — no file is read and nothing is parsed in either layer.
|
||||
|
||||
**Live check against the real shape** (read-only, `hw/ip/uart/rtl` of the
|
||||
owner's opentitan checkout, four files indexed, `git status` unchanged before
|
||||
and after):
|
||||
|
||||
| use in `uart_core.sv` | answer |
|
||||
|---|---|
|
||||
| `reg2hw.ctrl.tx.q` | `uart_reg_pkg.sv:159`, `logic q;` inside `} tx;` |
|
||||
| `reg2hw.ctrl.nco.q` | `uart_reg_pkg.sv:135`, `logic [15:0] q;` inside `} nco;` |
|
||||
| `reg2hw.fifo_ctrl.rxrst.qe` | `uart_reg_pkg.sv:215`, the `qe` of `} rxrst;` |
|
||||
| `hw2reg.status.txfull.d` | `uart_reg_pkg.sv:293`, `txfull`'s `d` — **not**
|
||||
`rxfull`'s, two lines up, which is the synthesized key earning its keep |
|
||||
|
||||
Four uses, four right answers, each four links deep through two levels of
|
||||
inline nested aggregate.
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-09-01 — dev agent.** Read CLAUDE.md, TODO.md §17, the
|
||||
class-member-access README in full (both rounds, both QA passes and both lead
|
||||
reviews), interface-semantics, types-decls and vlog-semantic rules 3/4/8
|
||||
before touching anything. The lead's map was accurate. Five decisions where it
|
||||
left latitude, and two deviations:
|
||||
|
||||
1. **`member_scope` is written as "any symbol whose child scope is a `Struct`
|
||||
scope", not "a `Typedef` whose child scope is one."** The brief asked for
|
||||
the narrow version, which would have needed two more special cases later —
|
||||
one for the anonymous `struct {…} s;` declarator and one for the inline
|
||||
nested member, neither of which is a `Typedef`. Written the general way, all
|
||||
three shapes are the same rule and there is nothing to keep in step. The
|
||||
check is on the *scope's* kind rather than the symbol's, so it cannot
|
||||
accidentally admit a class, a module or a package.
|
||||
2. **The synthesized key joins with `.`, not `::`.** The brief specified
|
||||
`reg2hw_t::ctrl`. That spelling does not survive `member_type`, which calls
|
||||
`last_segment` on a `Def::type_name` before using it — `reg2hw_t::ctrl`
|
||||
would become `ctrl`, a bare name that collides with every other `ctrl` in
|
||||
the workspace, which is the exact failure the synthesized key exists to
|
||||
avoid. A `.` survives `last_segment` whole, needs no special case anywhere,
|
||||
and is unwritable as a type name: `type_name_of` strips SystemVerilog's one
|
||||
dotted type spelling (`bus_if.mp`) down to the interface half before it is
|
||||
ever recorded, so no source can produce a colliding key. The
|
||||
`index.units(key)` ambiguity guard passes for free because no unit has a dot
|
||||
in its name.
|
||||
3. **The synthesized name lives on the `Def`, never on the `Symbol`.** Putting
|
||||
it on `Symbol::type_name` would have broken the in-file answer: `link_type`
|
||||
reads `type_name` *first* and only falls through to `member_scope` when
|
||||
there is none, so an inline member carrying `reg2hw_t.ctrl` would have gone
|
||||
to `type_here`, found nothing, and stopped the chain in the very file that
|
||||
declares it. In-file the scope is the answer; across files the key is. The
|
||||
two layers do not need the same representation and are better off not
|
||||
sharing one.
|
||||
4. **The binder's declaration half and use half are separate functions**
|
||||
(`bind_struct_members` / `bind_struct_uses`). One function that did both
|
||||
would have recorded a body's type names once *per declarator*, so
|
||||
`struct { hdr_t h; } a, b;` would post two references at the same span —
|
||||
two identical edits in a rename's edit set. Split, the pending-use order is
|
||||
byte-for-byte what it was before this round, because declarations record no
|
||||
pendings at all.
|
||||
5. **One enum helper for all three spellings.** `bind_enum_body` is called from
|
||||
the `typedef enum` arm and from `bind_data_type`'s inline arm, so an
|
||||
anonymous enum and a typedef'd one cannot drift.
|
||||
|
||||
**Deviation 1, argued: `a_chain_broken_by_a_struct_link_records_nothing_past_
|
||||
the_break`'s cross-file half stays "nothing".** The brief said the struct
|
||||
should answer there. It must not: that fixture puts a struct `hdr_t` in one
|
||||
file and an unrelated class `hdr_t` in another, so the workspace declares the
|
||||
name twice and `member_type`'s existing guard refuses the hop. Picking the
|
||||
struct because it is "the right one" would mean this layer choosing between two
|
||||
workspace declarations on a hunch — round 2's lesson, one hop out. The test is
|
||||
renamed `a_chain_continues_through_a_struct_link`, its in-file half flipped to
|
||||
resolve, its cross-file half kept as a *refusal* with the ambiguity premise
|
||||
asserted, and a third case added with the stranger removed, where the chain
|
||||
does land on the struct's field.
|
||||
|
||||
**Deviation 2, filed rather than done:** `typeDefinition` descends into a
|
||||
`typedef struct` body but not into an anonymous one written as a data
|
||||
declaration (`struct { hdr_t h; } s;`). `declarator_site` would have to take
|
||||
the cursor offset, which means touching all eight of its call sites for a shape
|
||||
the brief did not name. Filed in Handshakes.
|
||||
|
||||
**Pins flipped, all four in this lane's own files and all four because the
|
||||
round changes what is true:** `a_struct_typedef_typed_head_records_nothing` →
|
||||
`..._resolves_its_own_field` (with an absent-field case added, so the "records
|
||||
nothing" half of the rule is still pinned); `an_alias_of_a_struct_records_
|
||||
nothing` → `..._is_followed_to_its_fields`;
|
||||
`a_chain_broken_by_a_struct_link_records_nothing_past_the_break` →
|
||||
`a_chain_continues_through_a_struct_link` (see deviation 1); and
|
||||
`a_local_typedef_is_never_looked_up_in_a_same_named_class_elsewhere` **keeps
|
||||
its name and its point** — its premise line now reads 2 exports rather than 1,
|
||||
because this file's own struct is one of them, which is precisely why the
|
||||
reference is answered here and the workspace never asked. The two round-1 pins
|
||||
the brief said must stay (`an_alias_or_enum_typedef_typed_head_records_nothing`,
|
||||
`a_qualified_type_inside_an_in_file_package_records_nothing_unless_it_is_a_class`)
|
||||
are untouched and green, and both are re-attacked from the new angle in
|
||||
`struct_members.rs`.
|
||||
|
||||
**Nothing outside the lane's file list was touched.**
|
||||
`crates/vlog_refactor/tests/rename.rs:159`
|
||||
`a_struct_member_renames_where_it_is_declared` asserts the declaration only, on
|
||||
a fixture with no *use* of the member, so it keeps passing unchanged — the lead
|
||||
may want to extend it now that a use is renamed too; this lane's own e2e
|
||||
(`a_struct_field_is_renamed_with_its_uses_in_another_file`) pins the new
|
||||
behavior instead. `crates/lucisv_server/src/index_cache.rs` needed no change:
|
||||
8 → 9 is a census bump, not a layout one.
|
||||
|
||||
**Gates**, run to completion on this tree: `cargo fmt --all -- --check` clean;
|
||||
`cargo clippy --all-targets --workspace` zero warnings; `cargo test --workspace
|
||||
--no-fail-fast` **2 810 passed, 0 failed, 38 ignored**; `cargo build -p
|
||||
lucisv_server` clean; `node editors/vscode/smoke.js target/debug/lucisv-server`
|
||||
→ `smoke: OK`.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-01 — QA agent.** Read CLAUDE.md, TODO.md §17, and this README in
|
||||
full (Goal/Assumptions/Handshakes/work log) before touching anything.
|
||||
Verdict: **SHIP**.
|
||||
|
||||
**Gates**, re-run to completion on the unmodified working tree: `cargo fmt
|
||||
--all -- --check` clean; `cargo clippy --all-targets --workspace` zero
|
||||
warnings; `cargo test --workspace --no-fail-fast` → **2 810 passed, 0 failed,
|
||||
38 ignored** (summed from every `test result:` line, matches the dev's number
|
||||
to the digit); `cargo build --release` and `cargo build --release -p
|
||||
lucisv_server` clean; `node editors/vscode/smoke.js target/release/lucisv-server`
|
||||
→ `smoke: OK`.
|
||||
|
||||
**Scope.** `git diff --stat` against `95f930c`: `TODO.md`,
|
||||
`crates/lucisv_server/src/type_def.rs`, `crates/lucisv_server/tests/e2e.rs`,
|
||||
`crates/vlog_semantic/src/{bind,facts,resolve,workspace}.rs`,
|
||||
`crates/vlog_semantic/tests/member_access.rs`, three README amendments,
|
||||
`docs/topo.md`, plus new `crates/vlog_semantic/tests/struct_members.rs` and
|
||||
`docs/features/struct-members/`. No `vlog_parser`, `vlog_refactor` (source),
|
||||
`completion.rs`, `model.rs`, or `editors/*` touched — matches the brief. No
|
||||
`unwrap()`/`expect()`/`panic!` added to any library code path (checked the
|
||||
full diff of every changed `src/` file).
|
||||
|
||||
**Attack tests** (temporary, all in scratch, reverted after — none pin a bug,
|
||||
so nothing was folded in):
|
||||
|
||||
- `crates/vlog_semantic/tests/qa_attack.rs` (6 tests, deleted after running):
|
||||
a struct member typed as a **class** chases through it
|
||||
(`s.h.user_id` where `h: c1` inside a struct — resolves); **three-deep**
|
||||
inline nesting cross-file with a same-named leaf at each branch
|
||||
(`x.mid.inner_a.q` vs `x.mid.inner_b.q` — right sibling every time, lines 5
|
||||
vs 8 confirmed distinct); the synthesized key when the **owner is itself
|
||||
package-nested** (`p::reg2hw_t` with an inline `ctrl.q`) — confirmed the key
|
||||
stays the typedef's *bare* name (`reg2hw_t.ctrl`), matching the nested-class
|
||||
convention `collect_members` already used, not the package-qualified
|
||||
spelling; an inline nested field named the same as a real **file-scope
|
||||
module** elsewhere in the workspace (`ctrl` as both a module and a nested
|
||||
field) — no collision, resolves into the struct; **union** members resolve
|
||||
like struct members; two packages with a same-named struct typedef,
|
||||
approached through an explicit `pkg::` qualifier from a third file — never a
|
||||
silent cross-package pick (ambiguous or, if resolved, provably the qualified
|
||||
package's own field). All 6 passed on the first correct run (two initial
|
||||
failures were the test's own line-number arithmetic, 0- vs 1-indexed —
|
||||
`Def::lines.name` is 1-indexed, confirmed against the dev's own
|
||||
`the_register_package_shape_walks_four_links_across_files` pin).
|
||||
- `crates/vlog_refactor/tests/qa_attack_rename.rs` (2 tests, deleted after
|
||||
running): renaming one nested inline field (`tx`'s `q`, sibling `rx`'s `q`
|
||||
left alone) rewrites the declaration and every `owner.field` cross-file use,
|
||||
and does not leak into the sibling nesting level; renaming a struct
|
||||
typedef's own name (`bus_t` → `bus2_t`) leaves the field name (`addr`)
|
||||
completely untouched in both the declaring and the using file. Both passed.
|
||||
- `documentHighlight` was not separately attacked: `nav.rs::document_highlights`
|
||||
is generic over `symbol_at`/`occurrences` with no kind-specific branch, so it
|
||||
rides the same resolution already exercised above — read, not re-tested.
|
||||
|
||||
**Opentitan RTL — read-only**, release server `--verbose`, opentitan root as
|
||||
workspace (`index.scope: workspace`), hand-rolled Node LSP driver on stdio
|
||||
(`scratchpad/qa_driver.js`, modeled on `editors/vscode/smoke.js` and prior
|
||||
rounds' `qa_driver.js`). `git -C .../opentitan status --porcelain` before and
|
||||
after: unchanged (`hw/ip/aes/dv/tb/tb.sv`,
|
||||
`hw/{top_darjeeling,top_earlgrey}/ip/ast/rtl/ast.sv` only, the pre-existing
|
||||
state the charter names).
|
||||
|
||||
28 probes, 6 IPs (uart, spi_device, aes, i2c, usbdev, tlul) plus one DV file,
|
||||
hover + definition on each:
|
||||
|
||||
| use | file:line | answer | hover ms | def ms |
|
||||
|---|---|---|---:|---:|
|
||||
| `reg2hw.ctrl.tx.q` | `uart_core.sv` | `uart_reg_pkg.sv:159` | 3930* | 0 |
|
||||
| `reg2hw.ctrl.rx.q` | `uart_core.sv` | `uart_reg_pkg.sv:156` | 0 | 0 |
|
||||
| `reg2hw.ctrl.nco.q` | `uart_core.sv` | `uart_reg_pkg.sv:135` | 0 | 0 |
|
||||
| `reg2hw.fifo_ctrl.rxrst.q` | `uart_core.sv` | `uart_reg_pkg.sv:214` | 0 | 0 |
|
||||
| `reg2hw.fifo_ctrl.txrst.qe` | `uart_core.sv` | `uart_reg_pkg.sv:211` | 0 | 0 |
|
||||
| `reg2hw.cfg.tx_order.q` | `spi_device.sv` | `spi_device_reg_pkg.sv:164` | 5 | 0 |
|
||||
| `hw2reg.status.csb.d` | `spi_device.sv` | `spi_device_reg_pkg.sv:484` | 0 | 0 |
|
||||
| `hw2reg.status.tpm_csb.d` (sibling of csb) | `spi_device.sv` | `spi_device_reg_pkg.sv:481` | 0 | 0 |
|
||||
| `reg2hw.intr_enable.upload_cmdfifo_not_empty.q` | `spi_device.sv` | `spi_device_reg_pkg.sv:100` | 1 | 0 |
|
||||
| `reg2hw.intr_test.upload_cmdfifo_not_empty.qe` | `spi_device.sv` | `spi_device_reg_pkg.sv:135` | 0 | 0 |
|
||||
| `hw2reg.intr_state.upload_cmdfifo_not_empty.d` | `spi_device.sv` | `spi_device_reg_pkg.sv:463` | 0 | 0 |
|
||||
| `hw2reg.status.fmtfull.d` | `i2c_core.sv` | `i2c_reg_pkg.sv:549` | 3 | 0 |
|
||||
| `hw2reg.status.rxfull.d` **(the acid-test pair)** | `i2c_core.sv` | `i2c_reg_pkg.sv:546` | 0 | 0 |
|
||||
| `hw2reg.status.hostidle.d` | `i2c_core.sv` | `i2c_reg_pkg.sv:540` | 0 | 0 |
|
||||
| `hw2reg.rdata.d` (2-deep) | `i2c_core.sv` | `i2c_reg_pkg.sv:554` | 0 | 0 |
|
||||
| `hw2reg.host_fifo_status.fmtlvl.d` | `i2c_core.sv` | `i2c_reg_pkg.sv:562` | 0 | 0 |
|
||||
| `hw2reg.host_fifo_status.rxlvl.d` (sibling) | `i2c_core.sv` | `i2c_reg_pkg.sv:559` | 0 | 0 |
|
||||
| `reg2hw.fifo_ctrl.avsetup_rst.qe` | `usbdev.sv` | `usbdev_reg_pkg.sv:417` | 4 | 0 |
|
||||
| `reg2hw.fifo_ctrl.avout_rst.q` (sibling) | `usbdev.sv` | `usbdev_reg_pkg.sv:420` | 0 | 0 |
|
||||
| `hw2reg.usbstat.rx_empty.d` | `usbdev.sv` | `usbdev_reg_pkg.sv:593` | 1 | 0 |
|
||||
| `tl_i.a_address` (struct port, `tl_h2d_t`) | `tlul_adapter_reg.sv` | `tlul_pkg.sv:73` | 0 | 1 |
|
||||
| `tl_o.d_valid` (struct port, `tl_d2h_t`) | `tlul_adapter_reg.sv` | `tlul_pkg.sv:108` | 0 | 0 |
|
||||
| `item.a_addr` (DV, class member — unchanged) | `tl_agent/tl_monitor.sv` | `tl_seq_item.sv:45` | 1 | 0 |
|
||||
| `reg2hw.ctrl_aux_shadowed.key_touch_forces_reseed.q` | `aes_core.sv` | `aes_reg_pkg.sv:105` | — | — |
|
||||
| `reg2hw.trigger.start.q` | `aes_core.sv` | `aes_reg_pkg.sv:120` | — | — |
|
||||
| `reg2hw.status.output_lost.q` | `aes_core.sv` | `aes_reg_pkg.sv:132` | — | — |
|
||||
| `reg2hw.key_share0[i].q` | `aes_core.sv` | *no reference at all* | — | — |
|
||||
| `reg2hw.iv[i].q` | `aes_core.sv` | *no reference at all* | — | — |
|
||||
|
||||
\* First hover of the session pays the one-time answer-formatting warm-up;
|
||||
every hover/definition after it is sub-millisecond. **Zero wrong answers.**
|
||||
The three sibling "acid-test" pairs (`i2c` rxfull:546/fmtfull:549, `usbdev`
|
||||
avsetup_rst:417/avout_rst:420, `spi_device` tpm_csb:481/csb:484) were
|
||||
independently hand-verified by reading the generated `*_reg_pkg.sv` sources —
|
||||
every one lands on its own sibling's field, never the other's.
|
||||
|
||||
**The AES array misses are informational, not a struct-members defect.**
|
||||
`reg2hw.key_share0[i].q` and `reg2hw.iv[i].q` fail because the chain has an
|
||||
**indexed link mid-chain** (`key_share0[i]`), which `vlog-semantic`'s README
|
||||
(rule 8, "What is still head-only") and `class-member-access`'s README both
|
||||
document as out of scope *before this round and unrelated to it* — the same
|
||||
`a[i].b`/`q[i].x` limitation that already refuses at a class member. Confirmed
|
||||
by isolating the variable: three other AES chains through the very same
|
||||
wildcard-imported `aes_reg2hw_t` (`import aes_reg_pkg::*;`), with no index,
|
||||
answer correctly (`ctrl_aux_shadowed.key_touch_forces_reseed.q`,
|
||||
`trigger.start.q`, `status.output_lost.q` — all three above). The struct half
|
||||
is not what's missing here.
|
||||
|
||||
**Diagnostics**: all 7 opened files (`uart_core.sv`, `spi_device.sv`,
|
||||
`aes_core.sv`, `i2c_core.sv`, `usbdev.sv`, `tlul_adapter_reg.sv`,
|
||||
`tl_monitor.sv`) published **0 diagnostics** — unchanged from what a struct-
|
||||
unaware server would have shown on them (no regression this round could
|
||||
introduce fires here regardless).
|
||||
|
||||
**Timing.** Cold scan, `--verbose`, same 3 976-file / 3-skipped opentitan
|
||||
checkout: trunk `95f930c` **3 543.79 ms**; this tree **3 925.48 ms** — both
|
||||
comfortably in the same ballpark, reported honestly rather than rounded away
|
||||
(the 10.8% gap is consistent with page-cache/machine noise across two
|
||||
separate `cargo build --release` invocations minutes apart, not a hot-path
|
||||
change — `member_scope` and `member_type` both do the same O(1) extra work the
|
||||
README's cost section claims). Every hover and definition after the first
|
||||
warm one answered in **0.00–0.52 ms**, sub-millisecond as required.
|
||||
|
||||
**Store, opentitan on-disk index-cache** (the OS cache dir the server uses by
|
||||
default, `~/Library/Caches/lucisv/index/<workspace key>/index-cache` — same
|
||||
mechanism and same file `interface-semantics`'s QA measured): trunk `95f930c`
|
||||
**32 208 241 bytes** (matches that round's own reported "after" figure to the
|
||||
byte, a sanity check on the methodology) → this tree **33 583 533 bytes**,
|
||||
**+1 375 292 bytes (+4.27 %)**. This is a real, expected *gain*: the synthetic
|
||||
860-file corpus (no register packages) shrank 1.14 % because it converts
|
||||
external-candidate enum variants to local facts, but the README predicted a
|
||||
real RTL tree with generated `*_reg_pkg.sv` files would grow instead, because
|
||||
those files are almost entirely new exported `M` (member) entries with real
|
||||
content. Opentitan is exactly that tree; the number is the predicted direction
|
||||
and the QA methodology (trunk worktree build vs. this tree's build, same
|
||||
opentitan checkout, same on-disk cache path) matches the dev's own corpus
|
||||
comparison technique one level up, on the real target.
|
||||
|
||||
**Docs.** The feature README is complete against the template (all seven
|
||||
section headers present, Work log filled, Review reserved). All three
|
||||
amendments (`types-decls`, `vlog-semantic`, `class-member-access`) were
|
||||
re-read against the actual diff and are accurate — no claim in any of the
|
||||
three overstates or misdescribes what `bind.rs`/`resolve.rs`/`workspace.rs`
|
||||
actually do. The dev's five filed-not-done items (member completion after
|
||||
`.`, `typeDefinition` inside an anonymous data-declaration aggregate,
|
||||
cross-file anonymous struct variables, a package-nested class alias still
|
||||
unchased, and — noted here for the lead, not filed by the dev —
|
||||
`documentHighlight` was read rather than separately attacked, see Attack
|
||||
tests above) are all recorded either in this README's Handshakes or in this
|
||||
QA log for the lead to see.
|
||||
|
||||
**Verdict: SHIP.** No wrong answer found anywhere — not in six targeted
|
||||
adversarial unit-test attacks, not in two rename attacks, not across 28 real
|
||||
probes spanning 6 opentitan IPs plus a DV file, including three planted
|
||||
sibling-name acid tests hand-verified against source. The five misses are all
|
||||
the same documented, pre-existing, unrelated limitation (`a[i].b` mid-chain
|
||||
indexing). Gates green, scope respected, store growth is the predicted
|
||||
direction at a plausible magnitude, timing sub-millisecond, diagnostics clean.
|
||||
|
||||
## Review
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-01 — lead.** Approved and committed.
|
||||
|
||||
- Read the resolver and index hunks in full. The in-file fix is exactly the
|
||||
one gate the lead's map named — `member_scope` returning any symbol's
|
||||
child scope when that scope is a `Struct` scope, so typedef, anonymous
|
||||
declarator and inline nested field are one rule — and the fields moving
|
||||
to `declare_typed` is what lets a chain hop through a member's own type.
|
||||
- **The synthesized key is the round's real design**, and the dev's
|
||||
deviation from the brief is the right one: `.`-joined, not `::`-joined,
|
||||
because `member_type` runs `last_segment` on `Def::type_name` and `::`
|
||||
would have collapsed `reg2hw_t::ctrl` back to the bare `ctrl` the key
|
||||
exists to avoid. The `.` form is unwritable as a type name and passes the
|
||||
`units()` ambiguity guard for free. QA's three planted sibling pairs
|
||||
(`rxfull`/`fmtfull`, `avsetup_rst`/`avout_rst`, `tpm_csb`/`csb`) are the
|
||||
proof it works where it matters — opentitan's generated register
|
||||
packages — and the dev's own live check (`hw2reg.status.txfull.d` →
|
||||
`txfull`'s `d`, not `rxfull`'s two lines up) found it before QA did.
|
||||
- The cross-file stranger-class half of the old "chain broken by a struct
|
||||
link" pin correctly stays a refusal: two workspace declarations of
|
||||
`hdr_t` with different kinds is ambiguity, and the round-1 rule (nothing
|
||||
rather than a guess) holds one hop out.
|
||||
- Unresolved fell again, 1 203 → 1 162 (anonymous-enum variants that were
|
||||
external candidates are now resolved), and the corpus store *shrank*
|
||||
1.14 % because a resolved local fact encodes smaller than the candidate
|
||||
it replaced; opentitan's real register packages grow the store +4.27 %,
|
||||
reported honestly by QA, with hover at 0.00–0.52 ms.
|
||||
- Filed, carried forward: indexed mid-chain links (`reg2hw.key_share0[i].q`)
|
||||
— a pre-existing vlog-semantic limitation QA isolated from this round;
|
||||
`typeDefinition` inside an anonymous aggregate written as a data
|
||||
declaration; cross-file anonymous struct variables; the package-nested
|
||||
class-alias chase; and member completion after `.`, planned as TODO §18.
|
||||
- Gates re-run by the lead: fmt clean, clippy zero warnings, 2 810 passed /
|
||||
0 failed, smoke OK. `docs/topo.md`: §2.9-13 struck as delivered, handshake
|
||||
row added. Ships as 0.25.0 (FACTS_FORMAT 9).
|
||||
@@ -26,6 +26,11 @@ packed dimensions, a `type` parameter outside the `#( ... )` list — plus a
|
||||
- Enum member names introduced by an *anonymous* enum are not entered into the
|
||||
semantic model's scopes (only `typedef enum` members are). Nothing in the
|
||||
formatter needs them; see Handshakes.
|
||||
**Struck 2026-09-01 by struct-members** (`docs/features/struct-members/
|
||||
README.md`): they are now, in the scope holding the enum, exactly as a
|
||||
`typedef enum`'s are — and so are an anonymous struct's members and an
|
||||
inline nested member's. The assumption was only ever about what the
|
||||
*formatter* needed; the LSP gap it left is closed.
|
||||
- An anonymous `struct`/`union` body always breaks one member per line, like
|
||||
the `typedef struct` path it shares. An anonymous `enum` body is a group: one
|
||||
line if it fits, else one member per line — again the `typedef enum` rule.
|
||||
@@ -68,12 +73,18 @@ packed dimensions, a `type` parameter outside the `#( ... )` list — plus a
|
||||
|
||||
**Requests for other modules (not done here)**
|
||||
|
||||
- `vlog_semantic::bind` declares `typedef enum` members and `typedef struct`
|
||||
members as symbols (`bind.rs:395`, `bind.rs:406`). The equivalent members of
|
||||
an *anonymous* aggregate — `enum {A, B} x;`, the nested `struct packed {...}
|
||||
q;` of a register-package typedef — are not declared, so go-to-definition
|
||||
and hover do not find them. Purely an LSP completeness gap; the formatter
|
||||
and the corpus metric do not depend on it.
|
||||
- ~~`vlog_semantic::bind` declares `typedef enum` members and `typedef struct`
|
||||
members as symbols. The equivalent members of an *anonymous* aggregate —
|
||||
`enum {A, B} x;`, the nested `struct packed {...} q;` of a register-package
|
||||
typedef — are not declared, so go-to-definition and hover do not find
|
||||
them.~~ **Delivered 2026-09-01** by struct-members
|
||||
(`docs/features/struct-members/README.md`), which reads exactly the two
|
||||
hooks this section asked for: `DataType::inline()` and
|
||||
`TypeExtra::{Enum, Struct}`. An anonymous enum declares its variants in the
|
||||
enclosing scope; an anonymous `struct {…} s;` and an inline nested member
|
||||
each open a `Struct` scope of their own, so `s.a` and `reg2hw.ctrl.q`
|
||||
resolve, hover, navigate and rename. No parser change was needed — the AST
|
||||
this feature shipped was already the whole handshake.
|
||||
- `vlog_linter`'s `enum-name-style` / `struct-union-name-style` only look at
|
||||
`ItemKind::Typedef`, so an anonymous aggregate is out of their reach by
|
||||
construction. That is correct today (an anonymous type has no name to
|
||||
|
||||
@@ -114,14 +114,26 @@ Verilog requires at module scope — and as an editor needs mid-edit anywhere.
|
||||
3. **Enum variants land in the scope holding the enum**, per the LRM — not
|
||||
inside the typedef. `typedef enum { IDLE } state_e;` in a module binds both
|
||||
`state_e` and `IDLE` in that module.
|
||||
**Amended 2026-09-01 by struct-members**: so do an **anonymous** enum's
|
||||
(`enum {A, B} x;`) and those of an enum standing as a struct field's type,
|
||||
which declared nothing at all before — one binder function now serves all
|
||||
three spellings.
|
||||
4. **Struct members land in a `Struct` scope of their own**, hung under the
|
||||
typedef. Nothing ever *looks up* into it, so members cannot be reached as
|
||||
bare names — which is correct — but they are still symbols, so the outline
|
||||
can show them. A `Struct` scope is deliberately **not** one of the scopes
|
||||
the 2026-09-01 member access reaches into either (rule 8): a struct-typed
|
||||
`s.field` needs handshake §2.9-13 (anonymous aggregates declare no symbols
|
||||
at all) before it can answer the same question consistently, so it answers
|
||||
nothing rather than answering half the spellings.
|
||||
can show them.
|
||||
**Amended 2026-09-01 by struct-members** (`docs/features/struct-members/
|
||||
README.md`), which delivers §2.9-13 and strikes the paragraph that used to
|
||||
stand here (a `Struct` scope was "deliberately not one of the scopes member
|
||||
access reaches into", pending the anonymous forms). A member access **does**
|
||||
reach into one now, and consistently across every spelling: the scope hangs
|
||||
off the `typedef` that names the body, off the *declarator* of an anonymous
|
||||
`struct {…} s;`, or off an **inline nested** field, and `resolve.rs` accepts
|
||||
any symbol whose child scope is a `Struct` scope. Fields carry their own
|
||||
declared type, so `s.hdr.addr` hops through one. Bare-name lookup still
|
||||
never enters a struct scope, and no pending use is ever recorded inside one
|
||||
— a field's type, dimensions and initializer are bound in the scope the body
|
||||
is *written* in.
|
||||
5. **Imports.** `import p::*;` / `import p::x;` is recorded as an `Import` on
|
||||
the scope that wrote it (module header imports land on the module scope).
|
||||
Resolution consults it **only when `p` is a package declared in this
|
||||
@@ -170,15 +182,22 @@ Verilog requires at module scope — and as an editor needs mid-edit anywhere.
|
||||
two claims are different and only the first is honest here — and **a link
|
||||
that cannot be resolved honestly stops the chain**, so nothing is recorded
|
||||
for it or for anything after it. That covers: a type name **this file
|
||||
declares as something with no members** (a struct or enum `typedef`, a
|
||||
parameter, a shadowing variable), a member absent from a class this file
|
||||
declares whole, and — across files — a hop through a type name the
|
||||
workspace declares more than once. This file has answered what the type is,
|
||||
and asking the index for a same-named class elsewhere would answer a
|
||||
question the source never asked (QA finding 1 of round 1). Across files a
|
||||
module still exports only its **ports and parameters**, so `u.internal_sig`
|
||||
answers only when the module is in the same file (round 2's ruling, with
|
||||
the measurement, in the feature README).
|
||||
declares as something with no members** (an enum `typedef`, an alias of a
|
||||
built-in, a parameter, a shadowing variable), a member absent from a class
|
||||
or struct this file declares whole, and — across files — a hop through a
|
||||
type name the workspace declares more than once. This file has answered
|
||||
what the type is, and asking the index for a same-named class elsewhere
|
||||
would answer a question the source never asked (QA finding 1 of round 1).
|
||||
Across files a module still exports only its **ports and parameters**, so
|
||||
`u.internal_sig` answers only when the module is in the same file (round
|
||||
2's ruling, with the measurement, in the feature README).
|
||||
**Amended 2026-09-01 by struct-members**: a `struct`/`union` typedef is no
|
||||
longer one of the "no members" answers — see rule 4. `bus_t s; s.addr`
|
||||
resolves in-file, `pkg::bus_t s; s.addr` across files, and
|
||||
`reg2hw.ctrl.tx.q` walks four links through two levels of inline nested
|
||||
aggregate. The **rule** is untouched, and is what still refuses a stranger:
|
||||
a file that declares `bus_t` as a struct answers `s.field` itself, and an
|
||||
unrelated class `bus_t` elsewhere is never asked.
|
||||
9. **Type names are uses.** A declaration written with a user-defined type
|
||||
(`my_t x;`, `pkg::word_t y;`) records a reference for the type, so
|
||||
go-to-definition works on it. Built-in type keywords record nothing.
|
||||
@@ -201,7 +220,8 @@ region | generate block | for-generate header | for/foreach statement`.
|
||||
`genvar i;` written at module scope binds there instead, as the LRM says.
|
||||
- A `for`/`foreach` *statement* opens a scope for the same reason
|
||||
(`for (int i = 0; ...)`).
|
||||
- A `struct`/`union` body opens a `Struct` scope that lookup never enters.
|
||||
- A `struct`/`union` body opens a `Struct` scope that bare-name lookup never
|
||||
enters — and which, since 2026-09-01, a `.` member access does (rule 4).
|
||||
|
||||
### Simplifications (deliberate, all of them LRM-inexact)
|
||||
|
||||
|
||||
+2
-1
@@ -435,6 +435,7 @@ promise:
|
||||
| `class-member-access ◀──▶ workspace-index / index-persistence / vlog-semantic` | handshake | **`FACTS_FORMAT` 5 → 6** (2026-09-01): the field layout is unchanged but the reference census grew — `head.member` tails (`Target::MemberOf`, resolved head → `Symbol::type_name` → class scope → member, in-file `extends` chase) and names inside out-of-class method bodies (a stand-in `Class` scope carrying the class path as `extends`) are references now, so older stores must be discarded whole. `WorkspaceIndex::base_of` is a subclass → base map rebuilt in `merge` from the existing inheritance census (no new facts field); the cross-file chase lives in `follow_one` so hover, references and rename cannot disagree about what a tail names. `Symbol::type_name` is the declared type as written, deliberately absent on unpacked declarators (`c1 q[$]`) so `q.size()` never resolves against `c1`. `resolve` returns `Option`: a tail with nothing to say records no reference (not `NotFound`), keeping `a_hierarchical_name_resolves_only_its_head` and the unresolved count byte-stable. |
|
||||
| `class-member-access (round 2) ◀──▶ workspace-index / index-persistence / refactor-rename` | handshake | **`FACTS_FORMAT` 6 → 7** (2026-09-01): `Def::type_name` / `Decl::type_name` (the same capture rule as `Symbol::type_name`, now in `fingerprint`) and `ReferenceFact::External.base` (so `this.x`/`super.x` inherited uses post cross-file). Chains `a.b.c`: `Target::MemberOf { head, mids }` carries *spellings*, so the outer tail never depends on the inner's result — in-file `member_of` hops declared type → declared type; a chain leaving the file is ONE composed path `Unit::mid::tail` that `follow_one` walks via `member_type`, refusing a hop through a type name the workspace declares twice with different kinds. Instance heads: an instance symbol's `type_name` is its module; **modules export ports and parameters only** (lead ruling on measurement: nets/vars export cost +24 % store AND made `.port(w)` connections resolve to internal nets) — so `u.port` resolves cross-file, `u.internal` in-file only. Typedef-alias chase in `type_here`, file-scope typedefs cross-file. **Rename truth flipped**: `u_sub.sig` is sub's `wire sig` and is edited (`a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration`); an unresolvable tail is left alone but no longer warned about — §2.9-20. |
|
||||
| `interface-semantics ◀──▶ workspace-index / index-persistence / class-member-access / editor-scopes` | handshake | **`FACTS_FORMAT` 7 → 8** (2026-09-01): three new kind names (`Interface`, `Modport`, `Clocking`), no layout change. `SymbolKind::is_instantiable()` (`Module | Interface`) is the predicate every "is this a module" filter now reads — resolve (`Target::Module`/`Port`, container/member scopes), `is_unit`, the completion module table, `nearest_definition`/`module_header`, candidates, design hierarchy, call hierarchy, refactor `locate_module`/`module_definition`/`module_names` — each pinned in place; the sidebar's schema-2 wire shape is unchanged. Export: `Interface => Net | Var | Port | Param | Typedef | Function | Task | Modport | Clocking` (a module still exports ports and params only — round-2 ruling stands). Modport and clocking-block names are symbols; the names inside them are `Target::InScope` references (scope-local, nothing on a miss — a lexical walk would land a modport port on a file-scope lure); a clocking block carries `type_name` = its enclosing unit so `vif.cb.data` hops through round-2 machinery unchanged. The modport half of `bus_if.mp` in a type position is `Target::TypeMember { unit }`, resolved through `type_here`. `IndexCounts.interfaces` is separate so `modules` still means modules. Semantic-token legend deliberately not grown (indices are wire contract): Interface/Modport highlight as `class`, Clocking as `variable`. Rename truth flipped: a modport renames from its type-position use (`renaming_the_modport_half_of_a_port_type_renames_the_modport`). |
|
||||
| `struct-members ◀──▶ workspace-index / index-persistence / class-member-access / type-definition` | handshake | **`FACTS_FORMAT` 8 → 9** (2026-09-01): struct members exported (`is_exported(Typedef \| StructMember, StructMember)`), fields declared with `declare_typed` so `s.hdr.addr` hops through a member's own type, and `collect_members` recursing into package-nested struct typedefs (bare-name key, the nested-class convention — two packages with a same-named struct typedef collide by name and answer `Ambiguous`/nothing, never a guess) and into **inline nested fields under a synthesized key `owner.field` joined with `.`** carried as the field's `Def::type_name` — `.` not `::` because `member_type` runs `last_segment` on it and `::` would collapse to the bare field name; the key is unwritable as a type name and passes `units()`'s ambiguity guard for free. This is what makes opentitan's generated register packages resolve (`hw2reg.status.txfull.d` picks `txfull`'s `d`, not `rxfull`'s). `resolve::member_scope` accepts any symbol whose child scope is `ScopeKind::Struct` — typedef, anonymous declarator or inline field, one rule. `type_def.rs::alias_site` descends into `typedef struct` bodies. Corpus unresolved 1 203 → 1 162; store shrank 1.14 % (resolved anonymous-enum variants encode smaller than the external candidates they replaced). |
|
||||
| `define-table ◀──▶ macro-expansion` | handshake | What began as free-to-change became contract at M14: params stored **as written**, `NAME()` = `Some(vec![])` — `expand.rs` counts arguments against them and declines on mismatch. |
|
||||
|
||||
### 2.6 Refactor lane (the M-plan)
|
||||
@@ -534,7 +535,7 @@ update the filing README(s) and this file.
|
||||
| ~~10~~ | ~~`Fmt::raw_text`'s string-crossing path emits a `Doc::Text` carrying newlines~~ — **delivered 2026-08-26 (`53f2269`)**: both `raw_text` and the parameterized-type `#( … )` now emit `Doc::Inline`, whose printer arm resumes measuring from the text's own last line. directive-split's README (QA round 3 note) still documents it as open and should be struck there too | directive-split QA | ~~vlog_formatter~~ done |
|
||||
| 11 | Corpus scripts match `parse error:` / `lex error:` / `verification failed:` textually; a structured `--output-format json` for format mode would remove it | corpus-check | crates/lucisv |
|
||||
| 12 | `vlog_refactor::rename::Scope::build` re-derives sort-and-dedup by hand; could call `index_order` | indexing-ux | vlog_refactor |
|
||||
| 13 | Anonymous-aggregate members (`enum {A,B} x;`) not declared as symbols — hover/definition gap | types-decls | vlog_semantic |
|
||||
| ~~13~~ | ~~Anonymous-aggregate members (`enum {A,B} x;`) not declared as symbols — hover/definition gap~~ — **delivered 2026-09-01 by struct-members**: anonymous enum variants land in the enclosing scope via the shared `bind_enum_body`; an anonymous `struct {…} s;` declarator and every inline nested struct field carry their own `Struct` child scope, and `member_scope` accepts any symbol whose child scope is a `Struct` scope. Residue filed in the struct-members README: cross-file anonymous struct *variables*, `typeDefinition` inside an anonymous aggregate written as a data declaration | types-decls | ~~vlog_semantic~~ done |
|
||||
| 14 | A `program` node with `name_span`/`end_label_span` (today it lands in `Error`/verbatim), which would let linked-editing serve it with one arm | linked-editing | vlog_parser |
|
||||
| 15 | Bind semantics: whether a `bind`'s target scope and connections should resolve through the workspace index (today only the instantiated module name is recorded) | bind | vlog_semantic |
|
||||
| 16 | DPI/package re-export halves as real references (`export pkg::item` doesn't resolve; `*::*` has `"*"` as its package name, which nothing expects) | dpi-export | vlog_semantic |
|
||||
|
||||
Reference in new issue
Block a user