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

Add better error message on StackOverflow in macros, prevent SO in some cases with Scala 3 enums mapping #528

Merged
merged 4 commits into from
May 8, 2024

Conversation

MateuszKubuszok
Copy link
Member

@MateuszKubuszok MateuszKubuszok commented May 7, 2024

Description:

  • some snippets in our docs instead of generating reasonable code, generated StackOverflow in macros
  • investigation shown that it's caused by handling of Scala 3 enums - each parameterless case was treated as another enum, so we had "handle enum" calling "handle enum" calling "handle enum"...
    • of of the reasons was using Flags.enum when deciding if something is sealed
    • another was Flags.JavaStatic used to detect parameterless enum when - in those snippets - its was Flags.StableRealizable
  • it prevented SO, it generated a nice enableMacrosLogging messange... and compiler error :/

TODO 1: fix ignored snippets in docs once this is figured out

TODO 2:

  exception while retyping PaymentMethod.this of class This # -1

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose

     while compiling: /private/tmp/eldupa3/.scala-build/eldupa3_d091e5187c/src_generated/main/snippet.scala
        during phase: MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, etaReduce, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.3.3
            settings: -J<flag> List(-Xss128m) -classpath /Users/dev/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.3/scala3-library_3-3.3.3.jar:/Users/dev/.ivy2/local/io.scalaland/chimney_3/1.0.0-RC1-51-g4a37a24-SNAPSHOT/jars/chimney_3.jar:/Users/dev/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/dev/.ivy2/local/io.scalaland/chimney-macro-commons_3/1.0.0-RC1-51-g4a37a24-SNAPSHOT/jars/chimney-macro-commons_3.jar:/Users/dev/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-collection-compat_3/2.11.0/scala-collection-compat_3-2.11.0.jar -d /private/tmp/eldupa3/.scala-build/eldupa3_d091e5187c/classes/main -java-output-version 17 -sourceroot /private/tmp/eldupa3

in one of these snippets. Reported as scala/scala3#20349

Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 87.72%. Comparing base (4a37a24) to head (e62ccf0).

Files Patch % Lines
...chimney/internal/compiletime/DerivationError.scala 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #528      +/-   ##
==========================================
+ Coverage   87.60%   87.72%   +0.11%     
==========================================
  Files         136      136              
  Lines        5488     5440      -48     
  Branches      440      455      +15     
==========================================
- Hits         4808     4772      -36     
+ Misses        680      668      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MateuszKubuszok MateuszKubuszok added the blocked Ticket cannot be implemented because it depends on another ticker or external factor label May 7, 2024
@MateuszKubuszok MateuszKubuszok marked this pull request as ready for review May 8, 2024 12:40
@MateuszKubuszok MateuszKubuszok merged commit bd356ac into master May 8, 2024
23 of 24 checks passed
@MateuszKubuszok MateuszKubuszok deleted the fix-failing-snippets branch May 8, 2024 12:40
@MateuszKubuszok
Copy link
Member Author

After talking to @jchyb these fixes makes sense, but with the solution for a compiler crash we would probably have to wait for new compiler version, I'll merge it for now to proceed with docs improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Ticket cannot be implemented because it depends on another ticker or external factor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant