Scoped Edits — miri patch
miri patch replaces text inside one named function, then checks the whole file before saving. A
good edit is written:
$ miri patch scores.mi --replace-in-fn total_of_passing --old 's >= 5' --new 's > 5'
Applied 1 edit(s). The edited program checks.
exit status 0
An edit that would break the file is refused, and the file is left exactly as it was:
$ miri patch scores.mi --replace-in-fn total_of_passing --old 'total + s' --new 'total + s +'
error[MER_PAR_001]: Unexpected Token
--> scores.mi:10:3
|
10 | total
| ^ Expected an expression, but found end of expression
|
exit status 1
The text to replace must appear exactly once inside the function. patch works on files in Miri's
standard layout, so run miri fmt FILE first if the file was written by hand. Ordinary file edits work
just as well; patch is there for when you want the check before anything is saved.