Disallow simplifying empty assignment of dbg

This commit is contained in:
Joshua Warner 2024-12-28 22:28:29 -05:00
parent 59fe0f06ea
commit d8d0b6ebb1
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
6 changed files with 72 additions and 2 deletions

View file

@ -991,6 +991,7 @@ pub fn fmt_body<'a>(
&& !matches!(body.extract_spaces().item, Expr::Defs(..))
&& !matches!(body.extract_spaces().item, Expr::Return(..))
&& !matches!(body.extract_spaces().item, Expr::Backpassing(..))
&& !matches!(body.extract_spaces().item, Expr::DbgStmt { .. })
&& !starts_with_expect_ident(body)
} else {
false

View file

@ -360,8 +360,8 @@ impl<'a> Input<'a> {
* * * AST after formatting:\n{:#?}\n\n",
self.as_str(),
output.as_ref().as_str(),
ast_normalized,
reparsed_ast_normalized
actual,
reparsed_ast
);
}

View file

@ -0,0 +1,60 @@
@0-15 SpaceAfter(
Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-13,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@0-2 RecordDestructure(
[],
),
@5-10 SpaceBefore(
DbgStmt {
first: @9-10 Var {
module_name: "",
ident: "c",
},
extra_args: [],
continuation: @12-13 SpaceBefore(
Var {
module_name: "",
ident: "c",
},
[
Newline,
],
),
},
[
Newline,
],
),
),
],
},
@14-15 SpaceBefore(
Var {
module_name: "",
ident: "e",
},
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -0,0 +1,4 @@
{}=
dbg c
c
e

View file

@ -420,6 +420,7 @@ mod test_snapshots {
pass/empty_platform_header.header,
pass/empty_record.expr,
pass/empty_record_assign_backpassing.expr,
pass/empty_record_assign_dbg.expr,
pass/empty_record_assign_implements.expr,
pass/empty_record_assign_return.expr,
pass/empty_record_assign_tag.expr,