-
Notifications
You must be signed in to change notification settings - Fork 35
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
Gradualizer may fall into infinite loop for recursive types. #322
Comments
very nice minimal example |
Given a recursive type, typechecker:normalize() can recurse forever if we don't take care to stop the recursion. This patch adds a set to keep track of the types that `normalize` has unfolded so far and stops unfolding if asked to normalize a type that has already been unfolded. Ilya identified the problem with recursives types in #322 and offered a nice example program to demonstrate the problem. Fixes #322 although the program is still not accepted as it should be so I'm adding it to the known problems.
Not sure if a similar example has been covered already, but I'm seeing an infinite loop with the following code: -module(sample).
-compile([export_all]).
-type t() :: t().
-spec main() -> t().
main() -> ok. tested with |
@mheiber thanks for this example. I think it's a different issue. Types can refer to itself inside a tuple etc. but it's not allowed to be recursive on the top level, so we should detect it and give an error for this. |
Separate please (unless you think it will be solved by the same fix??) |
I think both issues have to do with checking subtype or type equivalence for recursive types–I suspect they will have a common solution. |
Given a recursive type, typechecker:normalize() can recurse forever if we don't take care to stop the recursion. This patch adds a set to keep track of the types that `normalize` has unfolded so far and stops unfolding if asked to normalize a type that has already been unfolded. Ilya identified the problem with recursives types in josefs#322 and offered a nice example program to demonstrate the problem. Fixes josefs#322 although the program is still not accepted as it should be so I'm adding it to the known problems.
Given a recursive type, typechecker:normalize() can recurse forever if we don't take care to stop the recursion. This patch adds a set to keep track of the types that `normalize` has unfolded so far and stops unfolding if asked to normalize a type that has already been unfolded. Ilya identified the problem with recursives types in josefs#322 and offered a nice example program to demonstrate the problem. Fixes josefs#322 although the program is still not accepted as it should be so I'm adding it to the known problems.
Given a recursive type, typechecker:normalize() can recurse forever if we don't take care to stop the recursion. This patch adds a set to keep track of the types that `normalize` has unfolded so far and stops unfolding if asked to normalize a type that has already been unfolded. Ilya identified the problem with recursives types in josefs#322 and offered a nice example program to demonstrate the problem. Fixes josefs#322 although the program is still not accepted as it should be so I'm adding it to the known problems.
A repro:
This goes into loop:
The text was updated successfully, but these errors were encountered: