gleam-lang / gleam

⭐️ A friendly language for building type-safe, scalable systems!
https://gleam.run
Apache License 2.0
17.26k stars 715 forks source link

Gleam format produces invalid code #2932

Closed chiefnoah closed 4 months ago

chiefnoah commented 4 months ago
diff --git a/test/cbor_gl_test.gleam b/test/cbor_gl_test.gleam
index fc094f4..8645a9d 100644
--- a/test/cbor_gl_test.gleam
+++ b/test/cbor_gl_test.gleam
@@ -99,7 +99,9 @@ pub fn decode_byte_string_test() {
   >>)
   |> should.be_ok()
   |> should.equal(
-    #(<<78:int-size(64), 78:int-size(64), 78:int-size(64), 78:int-size(64)>>, <<>>),
+    #(<<78:int-size(64), 78:int-size(64), 78:int-size(64), 78:int-size(64)>>, <<
+      ,
+    >>),
   )
 }

In the case of long lines with an empty BitString, gleam format tries to format <<>> as:


<<
,
>>

which is syntactically invalid. I've not found a workaround for this issue, as it appears <<>> is the only way to represent an empty BitString and gleam format is very opinionated.

Relevant repo/line here. See the failing CI pipeline for additional info.

chiefnoah commented 4 months ago

This was failing with Gleam v1.0.0 but is still failing with v1.1.0-rc1