-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stack overflow on subtype of large union for IArray[String] literal #7034
Comments
@ryanberckmans What is |
@ashwinbhaskar IArray is a new immutable array type in dotty. |
@ryanberckmans ah okay. |
I would love to give this a try if someone could just point me the way. |
@ryanberckmans Looking at the implementation of Is it possible to verify if this problem also happens with |
Which version are you running on, I have tried this with the code val arr = IArray("qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
"qwertyuiop",
//...7800 more times
) which compiles fine, including in the repl |
@bishabosha I'm on dotty 0.17.0-RC1. The |
@ashwinbhaskar looks like the stack overflow comes from subtype generation. The error is not specific to |
@ryanberckmans hmm..okay. Where is this subtype generation happening? |
@ashwinbhaskar I'm just a user and have no knowledge of dotty internals. Not sure I can help any further. Cheers |
This looks like an issue with opaque types and subtyping. It might be tricky to fix. |
My guess is the issue is with union types, not opaque types. Handling 5000+ element unions of singleton types is super hard. That's precisely the kind of scenario that motivated our initial design where unions could not contain singletons. I am unsure what to do here. In practice it seems that any union type larger than a couple of hundred operands is a waste of compiler resources and should be widened. But how to do that in a principled way? |
Progress has been made to fix this issue in #12928 however there is now a stack overflow in |
fix #7034: make mapWithIndexConserve tailrec
minimized code
With dotty 0.17.0-RC1
expectation
Expected this code to compile:
The text was updated successfully, but these errors were encountered: