mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-19 12:35:07 +00:00
Fix several fmt+parse bugs found by fuzzing
This commit is contained in:
parent
f0a74636a0
commit
b5f284cd78
14 changed files with 297 additions and 151 deletions
|
@ -243,10 +243,11 @@ impl<'a> Input<'a> {
|
|||
let reformatted = reparsed_ast.format();
|
||||
|
||||
if output != reformatted {
|
||||
eprintln!("Formatting bug; formatting is not stable.\nOriginal code:\n{}\n\nFormatted code:\n{}\n\nAST:\n{:#?}\n\n",
|
||||
eprintln!("Formatting bug; formatting is not stable.\nOriginal code:\n{}\n\nFormatted code:\n{}\n\nAST:\n{:#?}\n\nReparsed AST:\n{:#?}\n\n",
|
||||
self.as_str(),
|
||||
output.as_ref().as_str(),
|
||||
actual);
|
||||
actual,
|
||||
reparsed_ast);
|
||||
eprintln!("Reformatting the formatted code changed it again, as follows:\n\n");
|
||||
|
||||
assert_multiline_str_eq!(output.as_ref().as_str(), reformatted.as_ref().as_str());
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{ e & }
|
|
@ -0,0 +1,7 @@
|
|||
RecordUpdate {
|
||||
update: @1-2 Var {
|
||||
module_name: "",
|
||||
ident: "e",
|
||||
},
|
||||
fields: [],
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{e&}
|
|
@ -0,0 +1,4 @@
|
|||
[
|
||||
K,
|
||||
]
|
||||
- i
|
|
@ -0,0 +1,23 @@
|
|||
BinOps(
|
||||
[
|
||||
(
|
||||
@0-5 List(
|
||||
Collection {
|
||||
items: [
|
||||
@1-2 Tag(
|
||||
"K",
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
),
|
||||
@5-6 Minus,
|
||||
),
|
||||
],
|
||||
@6-7 Var {
|
||||
module_name: "",
|
||||
ident: "i",
|
||||
},
|
||||
)
|
|
@ -0,0 +1,2 @@
|
|||
[K,
|
||||
]-i
|
|
@ -0,0 +1,4 @@
|
|||
a : e
|
||||
Na :=
|
||||
e
|
||||
e0
|
|
@ -0,0 +1,54 @@
|
|||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
Index(0),
|
||||
],
|
||||
regions: [
|
||||
@0-3,
|
||||
@4-11,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 1, length = 0),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
type_defs: [
|
||||
Opaque {
|
||||
header: TypeHeader {
|
||||
name: @4-6 "Na",
|
||||
vars: [],
|
||||
},
|
||||
typ: @10-11 SpaceBefore(
|
||||
BoundVariable(
|
||||
"e",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
derived: None,
|
||||
},
|
||||
],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@2-3 BoundVariable(
|
||||
"e",
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
@12-14 Var {
|
||||
module_name: "",
|
||||
ident: "e0",
|
||||
},
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
a:e
|
||||
Na:=
|
||||
e e0
|
|
@ -304,6 +304,7 @@ mod test_snapshots {
|
|||
pass/empty_package_header.header,
|
||||
pass/empty_platform_header.header,
|
||||
pass/empty_record.expr,
|
||||
pass/empty_record_update.expr,
|
||||
pass/empty_string.expr,
|
||||
pass/equals.expr,
|
||||
pass/equals_with_spaces.expr,
|
||||
|
@ -327,6 +328,7 @@ mod test_snapshots {
|
|||
pass/list_closing_indent_not_enough.expr,
|
||||
pass/list_closing_same_indent_no_trailing_comma.expr,
|
||||
pass/list_closing_same_indent_with_trailing_comma.expr,
|
||||
pass/list_minus_newlines.expr,
|
||||
pass/list_pattern_weird_indent.expr,
|
||||
pass/list_patterns.expr,
|
||||
pass/lowest_float.expr,
|
||||
|
@ -389,6 +391,7 @@ mod test_snapshots {
|
|||
pass/opaque_reference_pattern.expr,
|
||||
pass/opaque_reference_pattern_with_arguments.expr,
|
||||
pass/opaque_simple.moduledefs,
|
||||
pass/opaque_type_def_with_newline.expr,
|
||||
pass/opaque_with_type_arguments.moduledefs,
|
||||
pass/ops_with_newlines.expr,
|
||||
pass/outdented_app_with_record.expr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue