Repository navigation
keep lambda params on one line - #127
Merged
Merged
Conversation
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A lambda's parameters stay on one line.
A lambda whose body is long used to break them one per line:
which buries the
fnunder 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 writesfn(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, sofmt(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 fmtover 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.