cli: add explicit source generics and Copy option/result

Specialize explicit function, struct and enum templates into deterministic
ordinary AIR, with structural constraints and bounded expansion. Preserve
source provenance and readable names in specialization diagnostics.

Add Copy-only std.option/std.result and vertical specification, grammar,
Quick Reference, RFC and source coverage updates. Keep linear aggregates
and existing unsupported source from-returns explicit follow-up work.

Repair the finite-layout check through arrays under the existing E1003
contract, with positive and rejected source/AIR fixtures.

Validation: build, unit tests, 640 conformance cases, 82/82 source constructs,
32-seed generic task stress, agent-reference, formatting, hosted smoke,
20 generic and 36 package CLI checks. Record three-encoding documentation
budgets; AIR reference is unchanged.
This commit is contained in:
dev committed 2026-10-06 19:53:26 +03:00
1 parent c96199e7ec
commit 7eea31518d
93 files changed
+1587 -75

No files matched your search

+13 -7
View File
@@ -18,17 +18,23 @@ item = type_decl | fn_decl ;
path = ident { "." ident } ;
type_decl = struct_decl | enum_decl ;
struct_decl = "struct" ident "{" [ field { "," field } [ "," ] ] "}" ;
struct_decl = "struct" ident [ type_params ] "{" [ field { "," field } [ "," ] ] "}" ;
field = ident ":" type ;
enum_decl = "enum" ident "{" variant { "," variant } [ "," ] "}" ;
enum_decl = "enum" ident [ type_params ] "{" variant { "," variant } [ "," ] "}" ;
variant = ident [ "(" type { "," type } ")" ] ;
fn_decl = "fn" ident "(" [ param { "," param } ] ")" "->" type [ "from" ident ]
fn_decl = "fn" ident [ type_params ] "(" [ param { "," param } ] ")" "->" type [ "from" ident ]
"effects" "[" [ path { "," path } ] "]"
block ; (* `trusted` is reserved and rejected, E7006 *)
param = ident ":" type ;
type_params = "<" type_param { "," type_param } ">" ;
type_param = ident [ ":" property { "+" property } ] ;
property = "Copy" | "Send" | "Share" | "Freeze" | "Local" ;
type_args = "<" type { "," type } ">" ;
application = "::" type_args ; (* explicit; no inference, spec 15 §15 *)
type = int_type | "bool" | "void" | "never" | path
| path type_args
| "[" type ";" int_lit "]"
| wrapper "<" type ">"
| "cap" "<" path ">"
@@ -64,7 +70,7 @@ if_expr = "if" expr block [ "else" ( if_expr | block ) ] ;
match_expr = "match" expr "{" { arm } "}" ;
arm = pattern "=>" ( block | expr "," ) ;
pattern = "_" | int_lit (* integer matches only; `_` is required there *)
| path "::" ident [ "(" ident { "," ident } ")" ] (* enum variant: Shape::Rect(w, h); no `_` in enum matches *)
| path [ application ] "::" ident [ "(" ident { "," ident } ")" ] (* enum variant: Shape::Rect(w, h); no `_` in enum matches *)
| ident [ "(" ident { "," ident } ")" ] ; (* outcome of a fallible operation: ok(n), closed *)
select_stmt = "select" "{" { select_arm } "cancelled" [ "(" ident { "," ident } ")" ] "=>" ( block | expr "," ) "}" ;
@@ -84,12 +90,12 @@ unary = ( "-" | "not" | "*" ) unary
| ( "ref" | "mut" ) [ "unchecked" ] place
| "move" ident
| postfix ;
postfix = primary { "." member | "[" expr [ ".." expr ] "]" | call_args } ;
postfix = primary { application | "." member | "[" expr [ ".." expr ] "]" | call_args } ;
member = ident | keyword ; (* after `.` a keyword is a name: task.cancelled *)
call_args = [ "<" type ">" ] "(" [ expr { "," expr } ] ")" ;
primary = int_lit | "true" | "false" | string
| ident | path "{" [ field_init { "," field_init } [ "," ] ] "}" (* struct literal; uppercase final component *)
| path "::" ident (* enum variant; applied by a call *)
| ident | path [ application ] "{" [ field_init { "," field_init } [ "," ] ] "}" (* struct literal; uppercase final component *)
| path [ application ] "::" ident (* enum variant; applied by a call *)
| "[" expr ";" int_lit "]"
| "(" expr ")"
| if_expr | match_expr | block ;