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:
21
readme.md
21
readme.md
@@ -106,14 +106,19 @@ z : s32 = ---; // uninitialized
|
||||
```
|
||||
|
||||
Builtin type names (`s2`, `u8`, `bool`, `string`, …) are reserved and a *bare*
|
||||
spelling can't be used as an identifier at **any** binding site — a value binding
|
||||
(`:=` / typed local / parameter), a `::` constant or function declaration, or a
|
||||
`::` type declaration (`struct` / `enum` / `union` / alias / `protocol` / …) — each
|
||||
is an error (`s2 :: 5` and `s2 :: (n) { … }` are rejected just like `s2 := 5`). A
|
||||
leading backtick escapes one into a **raw identifier**: `` `name `` is the literal
|
||||
identifier `name` (the backtick drops out of the text), usable in **every**
|
||||
position — value, declaration, and type. It is the only way handwritten sx can
|
||||
spell a reserved name.
|
||||
spelling can't be used as an identifier at a **value-binding or declaration-name**
|
||||
site — a value binding (`:=` / typed local / parameter), a `::` constant or
|
||||
function declaration, an `impl` method definition, or a `::` type declaration
|
||||
(`struct` / `enum` / `union` / alias / `protocol` / …) — each is an error
|
||||
(`s2 :: 5` and `s2 :: (n) { … }` are rejected just like `s2 := 5`). **Member-name
|
||||
positions are exempt**: a struct *field*, a union *tag*, and a protocol
|
||||
*method-signature* may be a bare reserved spelling (`struct { s2: s64 }`,
|
||||
`union { u8: … }`, `protocol { s2 :: (self) }`) — they are reached via `obj.name`,
|
||||
so they never mis-lower. A leading backtick escapes one into a **raw identifier**:
|
||||
`` `name `` is the literal identifier `name` (the backtick drops out of the text),
|
||||
usable in **every** position — value, declaration, and type, and optional in the
|
||||
exempt member positions. It is the only way handwritten sx can spell a reserved
|
||||
name in a binding or declaration site.
|
||||
|
||||
```sx
|
||||
`s2 := 2.5; // identifier "s2", distinct from the s2 type
|
||||
|
||||
Reference in New Issue
Block a user