Skip to main content

Module fix

Module fix 

Source
Expand description

#2642: check --fix — apply the machine-applicable suggestions of a file or project from the command line.

The selection rule is bynk_syntax::fix, the one the editor’s source.fixAll.bynk uses, so the two cannot disagree about what a pass takes. This module adds what a one-shot invocation needs and the editor leaves to the user pressing fix-all again:

  • A fixpoint (DECISION C). Re-check the edited text and re-apply until a pass takes no edits, capped at PASS_CAP passes. Past the cap two fixes are undoing each other: the run is refused.
  • A gate (DECISION D). A pass is accepted only if every diagnostic it introduces carries a single machine-applicable fix, so the next pass can resolve it. Any other new diagnostic needs a human, and the run is refused. The editor’s gate is stricter (no new diagnostic at all) because it applies once; a fixpoint has to allow the cascade it exists for.
  • Nothing written until the end (DECISION D/E). Every pass runs in memory over the source texts; only files whose text changed are written, in place, with no formatter pass.

Structs§

FixPlan
The outcome of a run that reached a fixpoint the gate accepted.
FixedFile
A file the run changed.
Scope
Which diagnostics’ fixes a run may take (#3537).

Enums§

Refusal
Why a run writes nothing.

Constants§

PASS_CAP
The most passes that may take edits. A fix that has not settled by then is two suggestions undoing each other.

Functions§

plan_file
plan_file_in over every diagnostic check shows.
plan_file_in
Plan the fixes for a single .bynk file. None when the file cannot be read: check reports that.
plan_project
plan_project_in over every diagnostic check shows.
plan_project_in
Plan the fixes for a project rooted at input. None when the project cannot be set up (a bad manifest, an unreadable lock): check reports that.