mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-23 03:52:27 +00:00
Fix approximately a bajillion fmt and parsing bugs
(discovered by fuzzing) There's more to come, but this seems like a good batch for now.
This commit is contained in:
parent
8f62eeaf7e
commit
0b8e68f70d
68 changed files with 1011 additions and 229 deletions
|
@ -72,12 +72,11 @@ fn fmt_spaces_max_consecutive_newlines<'a, 'buf, I>(
|
|||
// Only ever print two newlines back to back.
|
||||
// (Two newlines renders as one blank line.)
|
||||
let mut consecutive_newlines = 0;
|
||||
let mut encountered_comment = false;
|
||||
|
||||
for space in spaces {
|
||||
match space {
|
||||
Newline => {
|
||||
if !encountered_comment && (consecutive_newlines < max_consecutive_newlines) {
|
||||
if consecutive_newlines < max_consecutive_newlines {
|
||||
buf.newline();
|
||||
|
||||
// Don't bother incrementing it if we're already over the limit.
|
||||
|
@ -90,14 +89,14 @@ fn fmt_spaces_max_consecutive_newlines<'a, 'buf, I>(
|
|||
fmt_comment(buf, comment);
|
||||
buf.newline();
|
||||
|
||||
encountered_comment = true;
|
||||
consecutive_newlines = 1;
|
||||
}
|
||||
DocComment(docs) => {
|
||||
buf.indent(indent);
|
||||
fmt_docs(buf, docs);
|
||||
buf.newline();
|
||||
|
||||
encountered_comment = true;
|
||||
consecutive_newlines = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue