Fix indentation of single-line ifs

This commit is contained in:
Joshua Warner 2025-01-01 10:45:51 -05:00
parent 7fd97dec72
commit d9ad34592c
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
7 changed files with 87 additions and 10 deletions

View file

@ -0,0 +1,5 @@
f = if !b! then
""
else
e
""

View file

@ -0,0 +1,68 @@
@0-23 SpaceAfter(
Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-20,
],
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-1 Identifier {
ident: "f",
},
@2-20 If {
if_thens: [
(
@4-7 UnaryOp(
@5-7 Var {
module_name: "",
ident: "b!",
},
@4-5 Not,
),
@11-13 Str(
PlainLine(
"",
),
),
),
],
final_else: @19-20 SpaceBefore(
Var {
module_name: "",
ident: "e",
},
[
Newline,
],
),
indented_else: false,
},
),
],
},
@21-23 SpaceBefore(
Str(
PlainLine(
"",
),
),
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -0,0 +1,3 @@
f=if!b!then""else
e
""

View file

@ -1,8 +1,8 @@
@1-23 SpaceAfter(
@0-22 SpaceAfter(
If {
if_thens: [
(
@4-5 SpaceBefore(
@3-4 SpaceBefore(
SpaceAfter(
Var {
module_name: "",
@ -16,7 +16,7 @@
Newline,
],
),
@11-12 SpaceBefore(
@10-11 SpaceBefore(
SpaceAfter(
Tag(
"A",
@ -31,14 +31,14 @@
),
),
],
final_else: @20-23 SpaceBefore(
final_else: @19-22 SpaceBefore(
Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@20-21,
@19-20,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
@ -50,14 +50,14 @@
type_defs: [],
value_defs: [
Stmt(
@20-21 Var {
@19-20 Var {
module_name: "",
ident: "e",
},
),
],
},
@22-23 SpaceBefore(
@21-22 SpaceBefore(
Var {
module_name: "",
ident: "r",

View file

@ -454,6 +454,7 @@ mod test_snapshots {
pass/highest_float.expr,
pass/highest_int.expr,
pass/i_over_not_g.expr,
pass/if_bang_then_else_one_line.expr,
pass/if_def.expr,
pass/if_in_record_field_opt_pat.expr,
pass/if_newline_then_negate_else_recordupdater.expr,