feat(lang): backtick raw identifier in every binding form + raw-not-a-type + foreign reserved-name fn bare-call [F0.6]

Completes the issue-0089 backtick raw-identifier / `#import c` exemption
across all remaining identifier positions and closes three boundary gaps
the F0.6 review found.

1. Exhaustive raw-binding coverage. The `is_raw` bit now threads through
   `ast.Identifier` and EVERY binding/capture form — `IfExpr`/`WhileExpr`
   optional bindings, `ForExpr` capture + index, `MatchArm` capture,
   `CatchExpr`/`OnFailStmt` tag bindings, `DestructureDecl` per-name, and
   the protocol-default-body / foreign-class method param lists — not just
   `var_decl`/`param`. `UnknownTypeChecker` skips the reserved-name check at
   each arm when raw, so a backtick works in every identifier position while
   a bare reserved spelling still errors (issue 0076 preserved).

2. Raw identifier is never a type. `parseTypeExpr`'s atom rejects a raw
   identifier in type position (`x : `s2 = 1`, `List(`s2)`) with an accurate
   diagnostic instead of silently type-classifying it.

3. Reserved-name function bare-callable. A bare `s2(4)` parses its callee as
   a `.type_expr` (reserved spelling); `lowerCall` now rewrites a type_expr
   callee to an identifier when a function of that name is in scope, so a
   backtick-declared sx fn and a `#import c` foreign fn whose C name collides
   with a reserved type spelling both resolve by their bare name.
   (`TypeName(val)` is not a cast, so there is no ambiguity.)

Tests: examples/0152 (every control-flow/capture form + bare ref/call/member
access), examples/1054 (catch/onfail tag bindings), examples/1139 (raw in
type position rejected), examples/1220 extended (foreign reserved-name
function bare-call). 0076 negatives 1119/1121/1122/1123/1124/1125 stay green.
Gate: zig build + zig build test + 422 examples pass. specs.md + readme.md
updated; issues/0089 RESOLVED banner refreshed.
This commit is contained in:
agra
2026-06-04 18:31:08 +03:00
parent 0dbdc530ba
commit 640f59dc54
23 changed files with 356 additions and 56 deletions

View File

@@ -106,17 +106,26 @@ 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:
as bare value identifiers. A leading backtick at the **binding site** 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. The backtick is needed
only where the name is declared; a later bare reference in value position resolves
to the binding, while a bare `s2` in type position is still the type. It works in
every identifier position (local, global, parameter, field, function name, and the
control-flow / capture / binding forms — destructure, `if`/`while` binding, `for`
capture, match capture, `catch`/`onfail` tag), and a reserved-spelled function is
bare-callable:
```sx
`s2 := 2.5; // value identifier "s2", distinct from the s2 type
print("{}\n", `s2); // 2.5
print("{}\n", `s2); // 2.5 (or bare `s2`)
```
A raw identifier is a value name, never a type — `x : `s2 = 1` is an error.
Foreign declarations from `#import c { … }` are exempt automatically: C names that
collide with reserved type names (e.g. `s1`, `s2`) import unedited.
collide with reserved type names (e.g. `s1`, `s2`) import unedited, and a foreign
reserved-name function is bare-callable by its C name.
### Structs