docs(lang): keyword-spelled f32/f64 still need a backtick in member-name positions [F0.6]

The member-name exemption applies only to identifier-classified reserved
spellings (s1..s64, u1..u64, bool, string, void, usize, isize, Any). f32/f64
are lexer keywords (token.zig kw_f32/kw_f64) and member-name slots require an
identifier token, so a bare f32/f64 field/tag/method name is rejected at parse;
the backtick is required there too. specs.md + readme.md corrected.
This commit is contained in:
agra
2026-06-04 22:42:09 +03:00
parent d14e29be02
commit 685d3d122b
2 changed files with 14 additions and 1 deletions

View File

@@ -114,7 +114,11 @@ function declaration, an `impl` method definition, or a `::` type declaration
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**:
so they never mis-lower. The bare exemption covers only the identifier-classified
reserved names (`s1`..`s64`, `u1`..`u64`, `bool`, `string`, `void`, `usize`,
`isize`, `Any`); `f32` and `f64` are lexer keywords, so even in a member slot they
need the backtick (`` struct { `f32: s64 } ``). 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

View File

@@ -38,6 +38,15 @@ and `` obj.`s2 `` both resolve. The exemption covers member *signatures* only: a
slot), so a reserved-spelled impl method still needs the backtick
(`` `s2 :: (self) ``), exactly like a free function. See `examples/0158`.
The bare member-name exemption applies only to the **identifier-classified**
reserved spellings — `s1`..`s64`, `u1`..`u64`, `bool`, `string`, `void`, `usize`,
`isize`, `Any` — which all lex as ordinary identifiers. The two
**keyword-classified** reserved spellings, `f32` and `f64`, are lexer keywords, and
member-name slots require an identifier token; a bare `f32` / `f64` is therefore
rejected at parse (`expected field name in struct`) even in a member position. Use
the backtick there too — `` struct { `f32: s64; } `` / `` union { `f64: … } `` /
`` protocol { `f32 :: (self); } `` work as field / tag / method names.
```sx
s2 := 2.5; // ERROR: 's2' is a reserved type name and cannot be used as an identifier
s2 :: 5; // ERROR — a `::` constant name is a binding site too