apache / pekko-grpc

Apache Pekko gRPC
https://pekko.apache.org/
Apache License 2.0
37 stars 16 forks source link

chore:fix scalafmt HeadersSpec error because illegal unicode #297

Closed laglangyue closed 2 months ago

laglangyue commented 2 months ago

motivation

can't execute sbt scalafmtAll

invalid unicode surrogate pair
[error]         ("my favorite character is \ud801", "my favorite character is ?")

according to test in grpc-java, we should use 0xD801.toChar https://github.com/grpc/grpc-java/blob/79e75bace40cea7e4be72e7dcd1f41c3ad6ee857/api/src/test/java/io/grpc/StatusTest.java#L82-L92

raboof commented 2 months ago

huh, I could've sworn this syntax was allowed in Scala, but indeed I don't see it in https://scala-lang.org/files/archive/spec/2.13/01-lexical-syntax.html#string-literals

laglangyue commented 2 months ago

@raboof Here is a timeline: I started to discover the problem, and I thought it was a problem with scalafmt, but members of scalafmt thought it was an abandoned unicode, which is actually very rare. This symbol has a universal unicode Then I submitted a PR. Finally, I argued with scalafmt that they are compatible with this Unicode form and will not throw exceptions

laglangyue commented 2 months ago

Both writing methods are okay in Scala, and grpc-java uses (char) "xxx". This pr will not affect the our test. here is issue https://github.com/scalameta/scalameta/issues/3690 Because this issue occurs after this PR, So I didn't give any feedback on what happened afterwards to the Pekko community

raboof commented 2 months ago

both writing methods are okay in Scala

I agree the compiler currently appears to supports it, but I don't see anything in the language specification that says it must - so perhaps it would be best not to make assumptions? Or did I miss the part of the specification that covers this case?

https://github.com/scalameta/scalameta/issues/3690

Thanks for bringing the issue up there and adding the reference here!