Apply a breaking-change migration without an editor
Goal: bring a project up to a release whose breaking change the compiler can fix for you, from the command line, with no editor.
When a release makes something a hard error, its diagnostic often carries a fix
the compiler knows is exactly right (a machine-applicable suggestion). The
editor applies these through fix all. bynk check --fix applies the same
ones from a terminal or CI.
-
Start from a clean working tree, so the migration is one reviewable diff:
Terminal window git status --short # nothing listed -
Run the fixes from the project root (or a workspace root, which fixes every member, or none):
Terminal window bynk check --fixEach file written is listed, with the code each fix was for and how many diagnostics of that code it fixed:
fixed: src/shop.bynk: bynk.given.unused_capability ×3If the release’s upgrade note names a code, run only that migration:
Terminal window bynk check --fix=bynk.given.unused_capabilityList several codes with commas (
--fix=<a>,<b>). A code that does not exist is refused, with the nearest real one suggested, before anything is changed.The diagnostics that remain are reported as
checkreports them, and the exit code is non-zero if any error is left. -
Review and test what changed:
Terminal window git diffbynk test -
Format, if you want to.
--fixwrites the compiler’s text as it is and does not run the formatter, so a migration commit holds only the migration. Runbynk fmt .as a separate step or commit. -
Undo, if you need to, with
git checkout -- .. There is no dry-run flag: the diff is the preview.
When it refuses
Section titled “When it refuses”--fix writes nothing, and exits non-zero, in two cases:
- A fix would leave a problem that needs a human: a diagnostic with no single
machine-applicable fix, or a choice between candidates. The message names it.
Fix that one by hand, then run
--fixagain. - The fixes keep being applied for ten rounds, which means two of them are undoing each other. The message lists the codes involved; that is a compiler bug worth reporting.
Understand — the same fixes as the editor.
--fixapplies only the fixes of diagnosticsbynk checkshows, using the rule behind the editor’s fix all, so it never takes a fix a person would have to choose between. It differs in repeating the fixes until none remain, because a fix can expose another (adding a capability to an agent handler’sgivenmakes the provider that calls it short of the same capability), and in refusing the whole run rather than leaving a half-migrated tree.
See also: bynk check,
Editor support.