Skip to content

fix(fmt): keep named fun names unquoted - #86

Merged
mremond merged 1 commit into
mainfrom
inf/formatter-quotes-named-fun-names-and-breaks-01b8
Nov 23, 2026
Merged

mremond merged 1 commit into
mainfrom
inf/formatter-quotes-named-fun-names-and-breaks-01b8

Conversation

@mremond

@mremond mremond commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Why

The formatter added quotes to the name of a named fun, and the standard Erlang compiler refuses the result.

What changed

  • People who format Erlang code will notice that a named fun, such as fun Loop(0), keeps its name as written.
  • A name that truly needs quotes keeps them.

Before and after

Before: The formatter rewrote fun Loop(0) as fun 'Loop'(0), which stopped 8 of the project's 764 compiling Erlang files from compiling.

After: The formatter leaves fun Loop(0) unchanged, and those 8 files compile and run correctly on the standard Erlang runtime after formatting.

This changes the text the formatter writes, so there is no screen to show.

Checked

  • Formatted, compiled and ran a sample with two named funs: The old formatter's output failed to compile. The new output compiled and returned the right value.
  • Formatted all 818 Erlang files in the project and compiled them with the standard compiler: Files that stop compiling after formatting fell from 11 to 3.
  • Compared the new formatter's output with the old one on all 818 files: 810 files are identical, and 8 differ only by the removed quotes. Formatting twice changes nothing more.
  • Ran the 8 repaired test files on the standard Erlang runtime after formatting: All 8 compiled and ran correctly.
  • Ran the 3 new formatter tests ten times, and once against the old formatter: They passed all 10 runs, and all 3 failed on the old formatter.
How it was checked

cargo build --release --locked

cargo clippy --workspace --all-targets --locked -- -D warnings

cargo test --workspace --locked --no-fail-fast: 2256 passed, 0 failed, 1 ignored

python3 scripts/test-allocator-config.py

./target/release/nera test -j 1 --timeout 30: 543 passed, 0 failed, 2 skipped

python3 scripts/test-stacktrace-order.py

Risk

Risk: low in every dimension.

Full risk assessment
Dimension Level Why
Blast radius low Only how the formatter prints a named fun's name changes.
Behavior low Corrects a defect that produced invalid Erlang.
Undo low A revert restores the earlier output.
Evidence low Formatted files were compiled and run on the standard Erlang runtime.
Sensitivity low Touches no data, settings or sign-ins.
Novelty low A small helper in existing formatter code.
Dependencies low Adds no dependency.
Not done

Three of the project's test files still stop compiling after formatting, because a separate formatter defect drops parentheses they need.

@github-actions github-actions Bot added this to the 0.1.1 milestone Nov 23, 2026
@mremond
mremond merged commit 4a673be into main Nov 23, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant