Using Scala 3 seriously breaks default value handing
See original GitHub issueMinimal example:
case class A(a: Int = 1)
import upickle.default._
implicit val rw: ReadWriter[A] = macroRW[A]
println(read[A]("{\"a\":2}"))
println(read[A]("{}"))
Expected (upickle 1.4.0, Scala 2.13.6):
A(2)
A(1)
Got (upickle 1.4.0, Scala 3.0.1):
A(2)
A(2)
God knows how many projects are silently corrupting their databases. Or leaking data from another user in their API calls. Since the parser is keeping and leaking state, everything is possible.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Default values not working with @key annotation in Scala 3 ...
Exception in thread "main" java.lang.ExceptionInInitializerError at com.nitka.rb.RBSyncApp.main(RBSyncApp.scala) Caused by: upickle.core.
Read more >Scala default parameters and null
The correct default value can be picked by Scala tools, ... check and actual default value will break the contract established by the...
Read more >Optional Braces
Scala 3 enforces some rules on indentation and allows some occurrences of braces {. ... First, some badly indented programs are flagged with...
Read more >Optional Braces - Scala 3 - EPFL
Scala 3 enforces some rules on indentation and allows some occurrences of braces {. ... First, some badly indented programs are flagged with...
Read more >4. Functions - Learning Scala [Book]
With this procedure syntax, any return value (or final expression) will be discarded. To address this problem, it is recommended that developers stick...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maven doesn’t work that way, you can’t unpublish something. Also, that would break even more people’s deployments. That being said, this is a very high prio issue of course.
@jodersky if I’m not mistaken I think this is the fix
Looking at the Scala 3 macro code, it diverges from the Scala 2 implementation considerably; I haven’t benched it, but I bet the Scala 3 performance won’t be as good, as it seems to allocate a ton of stuff (it uses for-loops!? collections!?!? hashtables!?!?!?) that the Scala 2 version painstakingly avoids. We should definitely look into unifying them. They may do the same thing, but for a performance critical piece of code the Scala 2 version is what we want
Regardless, this small patch should fix this particular issue