ek9_fix_purity_contract
Adds or removes 'as pure' on the callable the diagnostic names, with the override cascade applied; answers status, edits[] and summary, the horizontal cascade as advisories[] and a mode/diagnosis mismatch as conflicts[].
When to use it
The compiler reported E05150 / E05160 / E08130 - 'fix the purity contract' is one call with file and the diagnostic's line; mode is inferred except for E08130.
When not to use it
- Proactively deciding a function should be pure (no compile error yet) - use
ek9_change_signature's change-purity mutation. - Purity change is part of a broader signature edit (params / return type / purity together) - use
ek9_change_signature. - The real fix is to factor pure logic out from impure logic - use
ek9_extract_method, then re-run this on the residual error.
Details
Modes: make-callee-pure / remove-pure-from-caller (E08130, opposite intents - pick by whether the callee body is genuinely pure-eligible; omitting mode there is a mode-required conflict listing both); add-pure-to-override (E05150) and remove-pure-from-override (E05160) are inferred when omitted. Conflicts gate the fix: no-purity-error-at-line, target-not-method-or-function, callee-not-resolvable; for E08130 modes an override anchor is refused (override-cascade-blocks-fix, pointing at the contract root) and an oversized transitive blast radius as cascade-too-large. The vertical override cascade is applied automatically; sub-threshold horizontal cascade sites come back as a purity-cascade advisory (chain this tool per site), and cascade-too-large is a design call - extract a pure core or pick the opposite mode.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
column | integer | IDE cursor offset (0-based) on 'line'. Omit it - pass symbol instead. | |
file | string | The .ek9 source file with the purity diagnostic (workspace-relative; an absolute path inside the workspace is accepted). Optional when symbol names the callable. | |
line | integer | 1-based line the compiler flagged (the diagnostic's own line). Omit it and pass symbol for an override (E05150/E05160), whose declaration IS the flagged line. | |
mode | string: make-callee-pure | remove-pure-from-caller | add-pure-to-override | remove-pure-from-override | The fix direction. Optional for E05150 (add-pure-to-override) and E05160 (remove-pure-from-override) - inferred from the diagnostic; required for E08130: make-callee-pure or remove-pure-from-caller. | |
symbol | string | The flagged callable - 'Shape.area' or a bare function name finds its file and declaration workspace-wide; with file (+ line), the identifier you mean there. |
It also takes the arguments every tool takes.
Recorded calls
Real calls, recorded against small projects and checked on every build - a changed answer fails it. 3 of the 7 recorded are shown.
No purity error conflicts
Request
{
"file" : "c.ek9",
"line" : 5,
"mode" : "make-callee-pure"
}
Response
{
"conflicts" : [ {
"kind" : "no-purity-error-at-line",
"message" : "No purity error (E08130 / E05150 / E05160) at c.ek9:5 — this tool is reactive; run it on the exact line the compiler flagged."
} ],
"edits" : [ ],
"meta" : {
"serverMs" : "<timing>"
},
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 0,
"lineCount" : 0,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "conflicts",
"summary" : "Cannot fix purity contract - 1 conflict",
"workspaceHash" : "<workspace-hash>",
"wouldBeDiagnostics" : [ ],
"written" : false
}
Override refuses to root
Request
{
"file" : "e.ek9",
"line" : 18,
"mode" : "remove-pure-from-caller"
}
Response
{
"conflicts" : [ {
"kind" : "override-cascade-blocks-fix",
"message" : "'doIt' is an override — its purity is fixed by the contract root 'Base.doIt'. Re-run on the root declaration (e.ek9:11).",
"rootFile" : "<workspace-root>/e.ek9",
"rootLine" : 11
} ],
"edits" : [ ],
"meta" : {
"serverMs" : "<timing>"
},
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 0,
"lineCount" : 0,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "conflicts",
"summary" : "Cannot fix method doIt - 1 conflict",
"workspaceHash" : "<workspace-hash>",
"wouldBeDiagnostics" : [ ],
"written" : false
...
Cut short here: 1 more lines. The whole recorded call.
Mode mismatch conflicts
Request
{
"file" : "a.ek9",
"line" : 10,
"mode" : "remove-pure-from-override"
}
Response
{
"conflicts" : [ {
"kind" : "mode-mismatch-with-diagnosis",
"message" : "mode 'remove-pure-from-override' expects E05160, but the purity diagnostic at line 10 is [E05150] — use one of [add-pure-to-override].",
"validModes" : [ "add-pure-to-override" ]
} ],
"edits" : [ ],
"meta" : {
"serverMs" : "<timing>"
},
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 0,
"lineCount" : 0,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "conflicts",
"summary" : "Cannot fix purity contract - 1 conflict",
"workspaceHash" : "<workspace-hash>",
"wouldBeDiagnostics" : [ ],
"written" : false
}
See also
- Show me in the IDE: Fix Purity Contract
- Fixes E05150
- Fixes E05160
- Fixes E08130