docs(lang): precise reserved-name rule — member-name positions are EXEMPT [F0.6]

AGRA RULING (issue 0089, attempt 7): bare reserved-name MEMBER positions are
intentionally exempt from the reserved-type-name rule, and the implementation
already does the right thing — this is a docs + one-example change, no code.

The exempt member positions are struct FIELD names, union TAG names, and protocol
method-SIGNATURE names: they sit in a member slot, are reached via obj.name (or
dispatched by string), and are never type-classified, so they never mis-lower.
The backtick is optional there. The exemption stops at member DEFINITIONS: an
impl method is a real function (reached through the impl_block -> fn_decl arm), so
a reserved-spelled impl method still needs the backtick, exactly like a free
function (cf. examples/1122) — and every bare reserved-name value binding /
declaration name still errors (0076 preserved).

- specs.md / readme.md: replace the "every binding site" / "any binding site"
  overclaim with the precise rule — required positions (value bindings +
  declaration names + impl method definitions) vs the exempt member-name
  positions (field / tag / protocol signature; backtick optional).
- examples/0158-types-reserved-name-member-exempt.sx: pins the exempt behavior —
  bare reserved-name struct fields + union tag read & written bare AND via
  backtick, and a protocol with a bare reserved-name method dispatched through
  the protocol (impl definition takes the backtick).
- issues/0089: document the member-name exemption in the RESOLVED banner + add
  0158 to the regression list.

Gate: zig build, zig build test, bash tests/run_examples.sh — all green
(430 passed, 0 failed, 0 timed out).
This commit is contained in:
agra
2026-06-04 22:17:53 +03:00
parent 724a919fc1
commit d14e29be02
7 changed files with 118 additions and 16 deletions

View File

@@ -58,6 +58,20 @@
> that omits them. `FnDecl` is built at every parser site through `parseFnDecl`,
> whose `name_is_raw` is a REQUIRED parameter (the equivalent guarantee); the
> type decls likewise route through parse-functions taking `name_is_raw`.
> - **Member-name positions are exempt** (Agra ruling, attempt 7). A struct
> **field** name, a union **tag** name, and a protocol **method-signature**
> name accept a bare reserved spelling: these sit in a member slot and are
> reached via `obj.name` / dispatched by string, so they are never
> type-classified and never mis-lower — the binding-name walk's `struct_decl`
> / `union_decl` / `enum_decl` / `protocol_decl` arms
> ([src/ir/semantic_diagnostics.zig]) check only the *type* name (and method
> *params*), not field / tag / variant / method-signature names. The backtick
> is optional there (`obj.s2` and `` obj.`s2 `` resolve to the same member).
> The exemption stops at member *definitions*: an `impl` method is a real
> function reached through the `impl_block` → `fn_decl` arm, so a
> reserved-spelled impl method needs the backtick (`` `s2 :: (self) ``), no
> more exempt than a free function (cf. `examples/1122`). Pinned by
> `examples/0158-types-reserved-name-member-exempt.sx`.
> 2. **`#import c` foreign-name exemption.** `c_import.zig` synthesizes foreign
> `#foreign` decls with `Param.is_raw = true` (and the synthesized `FnDecl`
> `is_raw = true`), so generated C names that collide with reserved type names
@@ -80,6 +94,9 @@
> `examples/0156-types-backtick-struct-const.sx` (struct-body const, untyped + typed),
> `examples/0157-types-backtick-parameterized-raw-type.sx` (raw parameterized type +
> pointer/field wrappers),
> `examples/0158-types-reserved-name-member-exempt.sx` (bare reserved-name struct
> fields / union tag / protocol method signature — read & written bare and via
> backtick; impl method definition takes the backtick),
> `examples/1054-errors-backtick-reserved-binding.sx` (`catch`/`onfail` tag
> bindings), `examples/1220-ffi-c-import-reserved-name-params.{sx,h,c}` (foreign
> param + fn-name exemption, bare-callable foreign fn); negatives