-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Stack overflow in TypeComparer #2874
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
Not yet. It would be important to add it, though. If someone volunteers to do it, would be mucg appreciated. |
@odersky do you have any comments/suggestions regarding porting the above code to Dotty? Why is the implementation of the cycle detection under scala/reflect, as opposed to tools/nsc? (I'm not familiar with the scalac code) |
@abeln In Dotty, the obvious place for putting these checks is in |
Ok, taking a look at this. Here's a simpler example (also from the paper) that doesn't use type refinements:
The sequence of subtype tests is as follows:
|
Expansive cycles characterize situations where the class hierarchy of a generic class is potentially infinite. This can lead to nontermination during subtype checks. This PR implements the algorithm in Kennedy, Andrew J., and Benjamin C. Pierce. "On decidability of nominal subtyping with variance." (2006). for detecting (and disallowing) expansive cycles.
Closing, since this is the same as #4805 |
Attempting to compile the following program causes a stack overflow in TypeComparer:
Stack trace
scalac rejects the program:
How I got to this program: this is Example 2 at the bottom of this paper. Both C# and (I guess) Scala implement a check for "expansive cycles" (see Section 9.2 of the CLR spec) that rejects this kind of program.
Does Dotty implement such a check?
The text was updated successfully, but these errors were encountered: