feat(lang): universal raw identifier — parser exhaustiveness + raw type continuations + sema/LSP [F0.6]

Closes the remaining three F0.6 findings so the universal backtick raw
identifier holds in BOTH classifiers and at EVERY parser construction site.

1. Struct-body constants thread is_raw + name_span. The struct-body const
   forms (untyped `` `s2 :: 5 `` and typed `` `s2 : T : v ``) built the
   const_decl node without name_span/is_raw, so a backtick const was falsely
   rejected and a bare reserved-name const caretted at 1:1. They now capture
   both. Structural cure: `ast.ConstDecl`'s name_span + is_raw carry NO
   default, so the compiler rejects any construction site that omits them
   (mirrors checkBindingName's required `is_raw` arg). FnDecl keeps its
   defaults — every parser fn_decl routes through parseFnDecl whose
   `name_is_raw` is a required parameter (equivalent guarantee).

2. Raw identifier in TYPE position flows through the normal continuations.
   parseTypeExpr no longer returns a terminal type_expr for a raw atom; the
   raw flag rides the atom through the qualified-path / Closure / parameterized
   continuations, so `` `s2(s64) ``, `` *`s2 ``, `` ?`s2 `` all parse.
   ParameterizedTypeExpr carries is_raw; resolveParameterizedWithBindings
   skips the `Vector` intrinsic when raw.

3. sema/LSP (the second classifier) honors is_raw. Type.fromTypeExpr returns
   null for a raw type_expr; resolveTypeNode skips the builtin classifier when
   raw; resolveTypeNameStr takes a skip_builtin arg threaded from te/id.is_raw
   (compound inner names pass false). A backtick reserved-name annotation now
   resolves to the user type in the editor index, not the builtin.

Tests: examples/0156 (struct-body const), 0157 (parameterized raw type +
wrappers), 1142 (bare struct-body const errors, caret on name); src/sema.test.zig
pins the LSP raw-type resolution (fail-before verified). Gate: 365 unit tests,
429 examples, 0 failed.
This commit is contained in:
agra
2026-06-04 21:14:35 +03:00
parent 023971cae5
commit ef8f021c01
22 changed files with 300 additions and 53 deletions

View File

@@ -55,13 +55,16 @@ x : s2 = 3; // bare `s2` in TYPE position is still the s2 int type
reference: it resolves to a `` `s2 ``-declared type (struct / enum / union / type
alias / …), and never the builtin. A bare `s2` in type position stays the builtin
int; a backtick name with no matching declaration is a normal `unknown type 's2'`
error.
error. A raw type reference flows through the **same continuations** as a bare type
name, so it parameterizes a reserved-spelled generic template (`` `s2(s64) ``) and
composes under the pointer / optional / slice wrappers (`` *`s2 ``, `` ?`s2 ``).
```sx
`s2 :: struct { x: s64; } // declare a type whose name is a reserved spelling
v : `s2 = ---; // reference it as a type — resolves to the struct
`s2 :: struct($T: Type) { x: $T; } // generic template with a reserved-spelled name
v : `s2(s64) = ---; // parameterized raw type reference
v.x = 7;
x : s2 = 3; // bare `s2` is still the 2-bit signed int
p : *`s2(s64) = @v; // wrappers compose over a raw type
x : s2 = 3; // bare `s2` is still the 2-bit signed int
```
**Declaration position.** A *bare* reserved-name declaration of every kind still
@@ -79,6 +82,7 @@ reference, and every control-flow / capture / binding form (destructure name,
`s2 : s64 : 5; // typed constant declaration
`u8 :: (`s1: s64) -> s64 { `s1 } // function name + parameter
P :: struct { `s2: f64; } // struct field
H :: struct { `s2 :: 5; } // struct-body constant (untyped + `: T :` typed)
M :: union { `s1: s32; } // union tag
`u16 :: enum { A; B; } // type-declaration name
`u8, rest := pair(); // destructure name