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

@@ -133,11 +133,14 @@ pub const FnDecl = struct {
call_conv: CallingConvention = .default,
/// Span of the function's name token, for the reserved-type-name decl
/// diagnostic (issue 0089). Synthesized decls (e.g. `#import c` foreign
/// functions) leave it zero.
/// functions, lowering-time objc/protocol method synthesis) leave it zero.
name_span: Span = .{ .start = 0, .end = 0 },
/// True when the function NAME was written as a backtick raw identifier
/// (`` `s2 :: … ``) or synthesized by a `#import c` foreign decl. A raw
/// name is exempt from the reserved-type-name binding check (issue 0089).
/// Every PARSER fn_decl is built through `parseFnDecl`, whose `name_is_raw`
/// is a REQUIRED parameter, so a parser site cannot drop it; the default
/// here serves only post-check synthesized decls (which are never raw).
is_raw: bool = false,
};
@@ -316,12 +319,15 @@ pub const ConstDecl = struct {
type_annotation: ?*Node,
value: *Node,
/// Span of the constant's name token, for the reserved-type-name decl
/// diagnostic (issue 0089).
name_span: Span = .{ .start = 0, .end = 0 },
/// diagnostic (issue 0089). NO default: every construction site must set
/// it explicitly, so a struct-body const can't silently fall back to a
/// 1:1 caret (the finding-1 bug).
name_span: Span,
/// True when the constant NAME was written as a backtick raw identifier
/// (`` `s2 :: … ``). A raw name is exempt from the reserved-type-name
/// binding check (issue 0089).
is_raw: bool = false,
/// (`` `s2 :: … ``). NO default: required at every site so the reserved-
/// name exemption can't be dropped — mirrors `checkBindingName`'s required
/// `is_raw` argument so the parser and the check can't desync (issue 0089).
is_raw: bool,
};
pub const VarDecl = struct {
@@ -573,6 +579,12 @@ pub const ArrayLiteral = struct {
pub const ParameterizedTypeExpr = struct {
name: []const u8, // e.g. "Vector", or later generic struct names
args: []const *Node, // e.g. [int_literal(3), type_expr("f32")]
/// True when the base name was a backtick raw identifier in type position
/// (`` `s2(s64) ``). Such a reference is the LITERAL name `s2` used as a
/// parameterized type — resolution skips the builtin parameterized
/// classifier (e.g. the `Vector` intrinsic) and instantiates a
/// `` `s2 ``-declared generic template (issue 0089).
is_raw: bool = false,
};
pub const IndexExpr = struct {