Fix double-wrapping of spaces before implements opaque keyword by making them distinct

This commit is contained in:
Joshua Warner 2025-01-03 18:47:21 -08:00
parent 8955f3e124
commit 6edfc0aa90
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
15 changed files with 313 additions and 251 deletions

View file

@ -24,16 +24,16 @@
"p",
),
derived: Some(
@18-20 SpaceBefore(
Implements(
[],
),
[
ImplementsAbilities {
before_implements_kw: [
LineComment(
"",
),
],
),
implements: @8-18,
after_implements_kw: [],
item: @18-20 [],
},
),
},
],

View file

@ -0,0 +1,57 @@
@0-25 SpaceAfter(
Defs(
Defs {
tags: [
EitherIndex(0),
],
regions: [
@0-23,
],
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: [
Opaque {
header: TypeHeader {
name: @0-1 "P",
vars: [],
},
typ: @3-4 Apply(
"",
"W",
[],
),
derived: Some(
ImplementsAbilities {
before_implements_kw: [
Newline,
],
implements: @7-17,
after_implements_kw: [
Newline,
],
item: @21-23 [],
},
),
},
],
value_defs: [],
},
@24-25 SpaceBefore(
Var {
module_name: "",
ident: "t",
},
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -81,8 +81,11 @@
[],
),
derived: Some(
@19-29 Implements(
[
ImplementsAbilities {
before_implements_kw: [],
implements: @8-18,
after_implements_kw: [],
item: @19-29 [
@20-22 ImplementsAbility {
ability: @20-22 Apply(
"",
@ -100,7 +103,7 @@
impls: None,
},
],
),
},
),
},
Opaque {
@ -126,8 +129,11 @@
],
),
derived: Some(
@74-84 Implements(
[
ImplementsAbilities {
before_implements_kw: [],
implements: @63-73,
after_implements_kw: [],
item: @74-84 [
@75-77 ImplementsAbility {
ability: @75-77 Apply(
"",
@ -145,7 +151,7 @@
impls: None,
},
],
),
},
),
},
Opaque {
@ -171,31 +177,31 @@
],
),
derived: Some(
@134-144 SpaceBefore(
Implements(
[
@135-137 ImplementsAbility {
ability: @135-137 Apply(
"",
"Eq",
[],
),
impls: None,
},
@139-143 ImplementsAbility {
ability: @139-143 Apply(
"",
"Hash",
[],
),
impls: None,
},
],
),
[
ImplementsAbilities {
before_implements_kw: [
Newline,
],
),
implements: @123-133,
after_implements_kw: [],
item: @134-144 [
@135-137 ImplementsAbility {
ability: @135-137 Apply(
"",
"Eq",
[],
),
impls: None,
},
@139-143 ImplementsAbility {
ability: @139-143 Apply(
"",
"Hash",
[],
),
impls: None,
},
],
},
),
},
Opaque {
@ -209,8 +215,11 @@
[],
),
derived: Some(
@165-187 Implements(
[
ImplementsAbilities {
before_implements_kw: [],
implements: @154-164,
after_implements_kw: [],
item: @165-187 [
@166-173 ImplementsAbility {
ability: @166-168 Apply(
"",
@ -244,7 +253,7 @@
),
},
],
),
},
),
},
Opaque {
@ -258,8 +267,11 @@
[],
),
derived: Some(
@208-222 Implements(
[
ImplementsAbilities {
before_implements_kw: [],
implements: @197-207,
after_implements_kw: [],
item: @208-222 [
@209-221 ImplementsAbility {
ability: @209-211 Apply(
"",
@ -280,7 +292,7 @@
),
},
],
),
},
),
},
Opaque {
@ -294,8 +306,11 @@
[],
),
derived: Some(
@243-263 Implements(
[
ImplementsAbilities {
before_implements_kw: [],
implements: @232-242,
after_implements_kw: [],
item: @243-263 [
@244-256 ImplementsAbility {
ability: @244-246 Apply(
"",
@ -324,7 +339,7 @@
impls: None,
},
],
),
},
),
},
Opaque {
@ -338,8 +353,11 @@
[],
),
derived: Some(
@284-304 Implements(
[
ImplementsAbilities {
before_implements_kw: [],
implements: @273-283,
after_implements_kw: [],
item: @284-304 [
@285-289 ImplementsAbility {
ability: @285-289 Apply(
"",
@ -368,7 +386,7 @@
),
},
],
),
},
),
},
Opaque {
@ -382,9 +400,12 @@
[],
),
derived: Some(
@325-327 Implements(
[],
),
ImplementsAbilities {
before_implements_kw: [],
implements: @314-324,
after_implements_kw: [],
item: @325-327 [],
},
),
},
Opaque {
@ -410,47 +431,47 @@
],
),
derived: Some(
@377-399 SpaceBefore(
Implements(
[
@378-385 ImplementsAbility {
ability: @378-380 Apply(
"",
"Eq",
[],
),
impls: Some(
@381-385 AbilityImpls(
[
@382-384 LabelOnly(
@382-384 "eq",
),
],
),
),
},
@387-398 ImplementsAbility {
ability: @387-391 Apply(
"",
"Hash",
[],
),
impls: Some(
@392-398 AbilityImpls(
[
@393-397 LabelOnly(
@393-397 "hash",
),
],
),
),
},
],
),
[
ImplementsAbilities {
before_implements_kw: [
Newline,
],
),
implements: @366-376,
after_implements_kw: [],
item: @377-399 [
@378-385 ImplementsAbility {
ability: @378-380 Apply(
"",
"Eq",
[],
),
impls: Some(
@381-385 AbilityImpls(
[
@382-384 LabelOnly(
@382-384 "eq",
),
],
),
),
},
@387-398 ImplementsAbility {
ability: @387-391 Apply(
"",
"Hash",
[],
),
impls: Some(
@392-398 AbilityImpls(
[
@393-397 LabelOnly(
@393-397 "hash",
),
],
),
),
},
],
},
),
},
Opaque {
@ -464,8 +485,11 @@
[],
),
derived: Some(
@420-427 Implements(
[
ImplementsAbilities {
before_implements_kw: [],
implements: @409-419,
after_implements_kw: [],
item: @420-427 [
@421-426 ImplementsAbility {
ability: @421-423 Apply(
"",
@ -479,7 +503,7 @@
),
},
],
),
},
),
},
],

View file

@ -553,6 +553,7 @@ mod test_snapshots {
pass/newline_after_sub.expr,
pass/newline_and_spaces_before_less_than.expr,
pass/newline_before_add.expr,
pass/newline_before_and_after_implements_opaque.expr,
pass/newline_before_import_curlies.expr,
pass/newline_before_sub.expr,
pass/newline_in_packages.full,