Skip to content

keep lambda params on one line - #127

Merged
alii merged 1 commit into
masterfrom
fmt-lambda
Sep 24, 2026
Merged

alii merged 1 commit into
masterfrom
fmt-lambda

Conversation

@alii

@alii alii commented Sep 24, 2026

Copy link
Copy Markdown
Member

A lambda's parameters stay on one line.

A lambda whose body is long used to break them one per line:

fn(
	acc,
	cp,
) result.then(…)

which buries the fn under its own arguments and reads as a call rather than a function. Parameters are short; breaking them buys a few columns and costs the shape. It now writes fn(acc, cp) result.then(…) and lets the call around it break instead.

A named function is unchanged: pub fn serve(host String, port Int, handler fn(Request) Response) … still breaks its parameters when the line is too long, and a signature the author broke by hand still stays broken.

This also retires a bug rather than guarding it. Three tests in the T-155 family reproduced an idempotence flip: pass one emitted fn(\n\td,\n), and the hard newlines in it made the lambda hug-eligible on pass two, so fmt(fmt(x)) != fmt(x). Those lambdas cannot wrap any more, so the flip has nowhere to start. The tests keep their programs and their round-trip assertion, and now assert that the parameters did not wrap.

Found by running scarlet fmt over the stdlib and reading what came out worse than what was written by hand.

All seven CI gates pass locally. hawk ran for the host target, and nothing here is gated on a cfg.

@alii
alii merged commit d4be575 into master Sep 24, 2026
4 checks passed
@alii
alii deleted the fmt-lambda branch September 24, 2026 01:10
@alii alii mentioned this pull request Sep 24, 2026
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