Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data constructors are sometimes incorrectly exploded #1436

Open
ag-eitilt opened this issue Oct 11, 2023 · 0 comments
Open

Data constructors are sometimes incorrectly exploded #1436

ag-eitilt opened this issue Oct 11, 2023 · 0 comments
Assignees
Labels
bug Something isn't working wake-format

Comments

@ag-eitilt
Copy link
Collaborator

This is likely rightfully two separate bugs, but they're closely-related enough that a fix to one is likely going to fix the other. First of all, if a data constructor with too long of a definition gets run through the formatter, it gets exploded and the exploded form is parsed as a completely different structure:

 data SomeData =
-    LongConstructor LongTypeName1 LongTypeName2 LongTypeName3 LongTypeName4 LongTypeName5 LongTypeName6 LongTypeName7
+    LongConstructor
+    LongTypeName1
+    LongTypeName2
+    LongTypeName3
+    LongTypeName4
+    LongTypeName5
+    LongTypeName6
+    LongTypeName7
     ShortConstructor

Data constructors this long aren't common and probably aren't great practice to begin with, but everything in this ticket can be replicated with simpler structures as well; I discovered it on private code with a constructor which only takes three parameters, but where each of those parameters has been annotated with a name for easier documentation.

The second, stranger bug is that this seems to be at least partially affected by comments preceding the constructor:

 data SomeData =
     LongConstructor LongTypeName1 LongTypeName2 LongTypeName3 LongTypeName4 LongTypeName5 LongTypeName6
     ShortConstructor

but

 data SomeData =
     # comment
-    LongConstructor LongTypeName1 LongTypeName2 LongTypeName3 LongTypeName4 LongTypeName5 LongTypeName6
+    LongConstructor
+    LongTypeName1
+    LongTypeName2
+    LongTypeName3
+    LongTypeName4
+    LongTypeName5
+    LongTypeName6
     ShortConstructor

It does seem like this is looking at the wrap length -- cutting it down so the line is only 100 characters wide stops all incorrect wrapping, though I've not taken the time to locate the breakpoint for the wrap-even-without-comment length.

@ag-eitilt ag-eitilt added bug Something isn't working wake-format labels Oct 11, 2023
@V-FEXrt V-FEXrt self-assigned this Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wake-format
Projects
None yet
Development

No branches or pull requests

2 participants