RFC-0021 · Reference catalog
Versioned draft snapshot
RFCs, reference catalogs, and evidence reflect Spec 3b2e3e7a114fb826b1445d39a48756b8fff629cd. Counts and pending/status notes belong to that snapshot. Read the dated project update for later progress.
Source repositories are private during staging. Links marked “repository access required” need access to the linked repository.
Generated reference catalog. This page renders structured Lean data for RFC-0021: defined terms, diagnostics, dependencies, and invariants. It does not establish proof coverage or runtime conformance. The authored narrative lives in
RFC-0021.This page is generated from the
lean/Gnomon/Spec/module for RFC-0021. Edit that source and regenerate this catalog.
Title: Transform Expression Language
Status: draft
Owners: Compiler
Diagnostic range: M21100-M21199
Proof citations in source: 15 / 15. Standalone proof verification is pending.
Definitions
| Term | Meaning |
|---|---|
| Total | A transform expression is total if it is guaranteed to produce a non-error value of the declared output type for every possible input value. |
| Transform Expression Language (TEL) | The pure, total, terminating sublanguage used to express field-level data transformations in migration declarations (RFC-0016). |
| input | The sole implicit binding in a transform expression; it refers to the current value of the field being transformed (the old value in the migration context). |
Diagnostics
| Code | Severity | Description |
|---|---|---|
M21101 | Error | External function call in transform expression; only built-in operations are permitted. |
M21102 | Error | Reference to a declaration other than input in transform expression; purity violation. |
M21103 | Error | Mutation operator in transform expression; transforms must be pure. |
M21104 | Error | Recursive reference detected in transform expression; recursion is not permitted. |
M21105 | Error | Loop construct in transform expression; loops are not permitted. |
M21106 | Error | Lambda or closure expression in transform; not part of the TEL sublanguage. |
M21107 | Error | Nullable input used in operation without null guard; may produce null propagation. |
M21108 | Error | Collection operation in transform expression; collection transforms are deferred. |
M21110 | Error | Conditional expression is missing the else branch; both branches are required for totality. |
M21111 | Error | Inferred LUB type of conditional branches is wider than the output field type. |
M21112 | Error | Invalid coercion path: no coercion exists from source type to target type. |
M21113 | Error | Inferred expression type is not assignable to the new field’s declared type. |
M21114 | Warning | Division by a denominator that is not statically proved non-zero. |
Invariants
- Any nullable input that is not statically guarded produces a compile error (M21107) rather than a runtime null-pointer error. (enforced by: compile-time)
- Every transform expression that compiles successfully is provably total: it terminates and produces a value for every possible non-error input. (enforced by: compile-time)
- Once RFC-0021 is ratified, M21101–M21114 replace M01603 for all transform-specific violations; M01603 is retained only for version-indeterminate malformed transforms. (enforced by: compile-time)
- The TEL grammar is a strict syntactic subset of RFC-0008 §11; every valid TEL expression is a valid RFC-0008 expression but not vice versa. (enforced by: compile-time)
- The output type of a compiled transform is statically guaranteed to satisfy the new field’s declared type, so no type error can occur at transform execution time. (enforced by: compile-time)
- Transform expressions have no observable side effects and are referentially transparent given the same input. (enforced by: compile-time)
Normative Statements
Statements are structured source data. Proof citations, where present, have not passed a standalone Gnomon proof gate.
Allowed and Prohibited Operations
- MUST — Arithmetic operands MUST be numeric types. (proof citation:
rfc0021_b13_grounded; verification pending) - MUST — Conditional expressions MUST include both then and else branches. (proof citation:
rfc0021_b9_grounded; verification pending)
Goals
- MUST — Every valid transform expression MUST be provably total — the compiler MUST statically prove termination and that the output satisfies the declared output type for every input. (proof citation:
rfc0021_b2_grounded; verification pending) - MUST — The TEL grammar MUST be a strict subset of the RFC-0008 §11 expression syntax. (proof citation:
rfc0021_b5_grounded; verification pending) - MUST — The compiler MUST emit specific M21xxx diagnostic codes for each class of violation, replacing the catch-all M01603. (proof citation:
rfc0021_b7_grounded; verification pending) - MUST — Transform expressions MUST be pure and MUST NOT cause I/O, mutation, or observable side effects. (proof citation:
rfc0021_b29_grounded; verification pending) - MUST — Type inference MUST be flow-sensitive within a single expression; conditional branch types MAY be narrower than the declared field type if both branches together cover it. (proof citation:
rfc0021_b23_grounded; verification pending)
Integration with RFC-0016
- MUST — The RFC-0016 compiler MUST recognise M21xxx codes and incorporate them into migration validation output. (proof citation:
rfc0021_b19_grounded; verification pending) - MUST_NOT — The deprecated (v) => expr lambda form from RFC-0016 §2.4.1 MUST NOT be used in new declarations. (proof citation:
rfc0021_b21_grounded; verification pending) - MUST — Tooling displaying M01603 MUST also display the deprecation notice and the superseding M21xxx code.
Totality-Checking Algorithm
- MUST — If input has a nullable type, the expression MUST handle the null case (e.g., via isNull guard). (proof citation:
rfc0021_b25_grounded; verification pending)
Type Inference Rules
- MUST — Both arithmetic operands MUST be numeric (Int or Float); modulo requires both Int. (proof citation:
rfc0021_b27_grounded; verification pending) - MUST — Both conditional branches MUST be present; a missing else produces M21110. (proof citation:
rfc0021_b15_grounded; verification pending) - MUST — The compiler MUST verify a valid coercion path exists from the source type to the target type per RFC-0006. (proof citation:
rfc0021_b17_grounded; verification pending) - MUST — The compiler MUST verify the inferred expression type is assignable to the new field type. (proof citation:
rfc0021_b0_grounded; verification pending) - MUST — The conditional inferred LUB type MUST be a subtype of (or equal to) the new field type, else emit M21111. (proof citation:
rfc0021_b11_grounded; verification pending)
Linked References
(no cross-RFC dependencies)