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
[2.13.9, 2.13.10] Issue with zio-prelude 1.0.0-RC8-1
(zio1) macros
#12647
Comments
1.0.0-RC8
(zio1) macros
1.0.0-RC8
(zio1) macros1.0.0-RC8-1
(zio1) macros
is the problem also reproducible without are you able to minimize to a self-contained test, without external dependencies? |
the "without external dependencies" part is important |
I don't know how the zio-prelude macros are implemented. So, I'm not sure I can provide you this, sorry. |
Very likely that it's the same issue as #12645. |
do you know anyone involved with ZIO maintenance who could help with the minimization? |
These macros have been implemented and are maintained by Kit Langton (@kitlangton) |
1.0.0-RC8-1
(zio1) macros1.0.0-RC8-1
(zio1) macros
Okay, I'm tentatively closing this ticket, then. We can reopen if more information comes to light. |
The fix made in Scala 2.13.10 (ie. #10160) doesn't seem to fix this issue. [info] Non-compiled module 'compiler-bridge_2.13' for Scala 2.13.10. Compiling...
[info] Compilation completed in 8.166s.
[error] -target is deprecated: Use -release instead to compile against the correct platform API.
[error] /home/runner/work/my-project/src/main/scala/my/company/project/types/primitives.scala:
[error] Newtype Assertion Failed
[error] We were unable to read your assertion at compile-time.
[error] This is because you have annotated `def assertion` with its type signature:
[error]
[error] override def assertion: QuotedAssertion[Int] = assert(...)
[error]
[error] Due to the macro machinery powering this feature, you MUST NOT ANNOTATE this method.
[error] Try deleting the type annotation and recompiling. Something like:
[error]
[error] override def assertion = assert(...)
[error]
[error] val one = PosInt(1) The corresponding code: import zio.prelude.*
object PosInt extends Subtype[Int] {
override def assertion = assert(greaterThan(0))
val one = PosInt(1)
}
type PosInt = PosInt.Type |
1.0.0-RC8-1
(zio1) macros1.0.0-RC8-1
(zio1) macros
Indeed. The original change in 2.13.9 (scala/scala#9891) is to use the overridden method's type under
To the macro, the tree then looks like the result type was explicit. The fix in 2.13.10 (scala/scala#10160) only reverts that rule within expanding / type checking a macro. However, here the type-checking of What code is the macro using to tell whether the return type was explicit or not? I believe the following should work correctly for 2.13.9/10 and also before:
|
Thanks for the suggestion @lrytz. I'll see with ZIO people if we can try this change. |
Possibly the improved check in the PR is viable, so I'll reopen. |
@som-snytt is your fix working? @SethTisue If the fix is working, is it possible to merge it and make a new release, please? Because of this bug, we're blocked on Scala 2.13.8 which contains a severe CVE 😟 |
The CVE can be exploited in applications that deserialize untrusted data, which is always a security risk. The fix in 2.13.9 / 10 targets a specific, known entry point in the Scala library. But it's very likely that an application's classpath contains other, similar entry points. So in that sense, it's not severe. We're currently planning 2.13.11 on the usual schedule (3-4 months). If you'd like to use 2.13.10, it should be possible to implement a workaround in the macro. |
@guizmaii It would be helpful if you gave the PR snapshot a try yourself and see if it resolves your issue. There are instructions on using PR validation snapshots at https://github.com/scala/scala/blob/2.13.x/README.md#scala-ci |
The PR is now merged, so it'll be available for testing in 2.13.11-bin-8fa1e7c (which CI should build within the next few hours). |
Thanks @SethTisue. Sorry, I wasn't able to find time to test the PR. This release will simplify my task of testing it. I'll come back to you with the results |
2.13.11-bin-8fa1e7c is now published
|
My
For my benefit, my build.sbt
I had to reread the docs to refresh my memory. I accidentally tested that it still fails without pulling in my fix. Also, note to self, the quasi-companion works because |
I can confirm that my code is compiling with this Thanks everyone for your help! ❤️ |
There's an issue between Scala 2.13.9 and zio-prelude
1.0.0-RC8-1
(last version published supporting ZIO1) macros:is failing to compile with the following error:
This was compiling fine with Scala 2.13.8.
Note that we're using the
-Xsource:3
flag.The text was updated successfully, but these errors were encountered: