mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +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
|
@ -77,6 +77,7 @@ impl<'a> Formattable for TypeDef<'a> {
|
|||
for var in *vars {
|
||||
buf.spaces(1);
|
||||
fmt_pattern(buf, &var.value, indent, Parens::NotNeeded);
|
||||
buf.indent(indent);
|
||||
}
|
||||
|
||||
buf.push_str(" :");
|
||||
|
@ -95,6 +96,7 @@ impl<'a> Formattable for TypeDef<'a> {
|
|||
for var in *vars {
|
||||
buf.spaces(1);
|
||||
fmt_pattern(buf, &var.value, indent, Parens::NotNeeded);
|
||||
buf.indent(indent);
|
||||
}
|
||||
|
||||
buf.push_str(" :=");
|
||||
|
@ -136,6 +138,7 @@ impl<'a> Formattable for TypeDef<'a> {
|
|||
for var in *vars {
|
||||
buf.spaces(1);
|
||||
fmt_pattern(buf, &var.value, indent, Parens::NotNeeded);
|
||||
buf.indent(indent);
|
||||
}
|
||||
|
||||
buf.push_str(" has");
|
||||
|
@ -191,6 +194,7 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
match self {
|
||||
Annotation(loc_pattern, loc_annotation) => {
|
||||
loc_pattern.format(buf, indent);
|
||||
buf.indent(indent);
|
||||
|
||||
if loc_annotation.is_multiline() {
|
||||
buf.push_str(" :");
|
||||
|
@ -390,6 +394,7 @@ pub fn fmt_body<'a, 'buf>(
|
|||
indent: u16,
|
||||
) {
|
||||
pattern.format_with_options(buf, Parens::InApply, Newlines::No, indent);
|
||||
buf.indent(indent);
|
||||
buf.push_str(" =");
|
||||
|
||||
if body.is_multiline() {
|
||||
|
@ -415,7 +420,7 @@ pub fn fmt_body<'a, 'buf>(
|
|||
);
|
||||
}
|
||||
}
|
||||
Expr::BinOps(_, _) => {
|
||||
Expr::Defs(..) | Expr::BinOps(_, _) => {
|
||||
// Binop chains always get a newline. Otherwise you can have things like:
|
||||
//
|
||||
// something = foo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue