feat(lang): backtick raw-identifier escape + #import c foreign-name exemption [F0.6]

Reserved type-name spellings (s1, s2, u8, …) can now be used as value
identifiers two ways, resolving issue 0089:

1. Backtick raw identifier: a leading backtick (`s2) lexes to an
   .identifier token carrying a new Token.is_raw flag, with the backtick
   excluded from the text. A raw identifier is never type-classified — the
   parser skips Type.fromName for it — so it is always a value identifier.
   The flag threads to VarDecl.is_raw / Param.is_raw at binding sites, and
   the reserved-type-name check (UnknownTypeChecker) skips raw bindings.
   Because the token tag stays .identifier, the escape works in every
   position (local, global, param, field, fn name, struct member, later
   reference) with no per-site parser change.

2. #import c exemption: c_import.zig synthesizes foreign decls with
   Param.is_raw = true, so generated C param names that collide with
   reserved type names (s1, s2) import unedited.

A bare reserved-name binding in sx still errors (issue 0076 preserved):
the is_raw-gated skip only fires for backtick / foreign names, and a raw
binding's address-of / autoref lowering stays correct because every
occurrence is an .identifier, never a .type_expr.

Tests: examples/0151 (backtick, every position),
examples/1220 (foreign exemption, compiled+run), lexer unit tests.
1119 (bare-binding rejection) stays green. specs.md + readme.md updated.
This commit is contained in:
agra
2026-06-04 17:40:42 +03:00
parent 7911494809
commit 0dbdc530ba
19 changed files with 317 additions and 14 deletions

View File

@@ -105,6 +105,19 @@ y : s32 = 0; // explicit type
z : s32 = ---; // uninitialized
```
Builtin type names (`s2`, `u8`, `bool`, `string`, …) are reserved and can't be used
as bare value identifiers. A leading backtick escapes one into a raw identifier — its
text drops the backtick and it's never read as a type — so reserved spellings (and
keywords) work as ordinary names:
```sx
`s2 := 2.5; // value identifier "s2", distinct from the s2 type
print("{}\n", `s2); // 2.5
```
Foreign declarations from `#import c { … }` are exempt automatically: C names that
collide with reserved type names (e.g. `s1`, `s2`) import unedited.
### Structs
```sx