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
@@ -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)
|
||||
|
||||
|
||||
Reference in new issue
Block a user