-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Large enum (1000 cases) causes StackOverflowError #10174
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
Comments
/cc @liufengyun EDIT: so for clarity, I guess that this warning comes from checking pat-mat on compiler-emitted code. I think that in pathological cases like the above, it might make sense to simply give up on detecting patmat exhaustivity, and possibly emit a warning saying as much. I know that Haskell does something like that when the GADT constraint set becomes too complicated. |
I think that's a good strategy to avoid hanging or crashing the compiler. For this particular case, it's also good to have a look and see if we can improve the algorithm a little bit. |
scala 2 also has an analysis budget based on the formula size and recursion depth: https://github.com/scala/scala/blob/710154924085d69edda1de95bc674bbd8a89e7cd/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala#L372-L387 |
Fix #10174: avoid creating deep nesting union space
An enum with 1000 value cases will cause a crash:
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: