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

Fix an issue with infinite loops while typechecking some expressions #4274

Merged
merged 11 commits into from
Dec 23, 2022

Conversation

jasoncarr0
Copy link
Contributor

@jasoncarr0 jasoncarr0 commented Dec 13, 2022

Some recursive constraints in type signatures could result in infinite loops while typechecking in cases where the typechecking should have succeeded.

This fixes those cases.

Fixes #3658

The fix works by making these cases more coinductive: pushing the assumption before typechecking equality of expressions.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Dec 13, 2022
@jasoncarr0
Copy link
Contributor Author

jasoncarr0 commented Dec 13, 2022

Only thing WIP I just need to find a good test for it and it could possibly serve to be cleaner. Running manually against the test cases so far seems to work correctly.

@jasoncarr0 jasoncarr0 force-pushed the subtyping-infinite-loops-fix branch from baae452 to 89197c3 Compare December 13, 2022 07:17
@jemc jemc added the do not merge This PR should not be merged at this time label Dec 13, 2022
@jemc
Copy link
Member

jemc commented Dec 13, 2022

Marking as "do not merge" because the testing is WIP.

@jemc jemc removed the discuss during sync Should be discussed during an upcoming sync label Dec 13, 2022
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Dec 13, 2022
@jemc jemc removed the discuss during sync Should be discussed during an upcoming sync label Dec 13, 2022
@mfelsche
Copy link
Contributor

@jasoncarr0 Can you explain someone like me who tried to look into it without success, how this fixes the subtype check recursion and for what kind of types this works? I am very curious but unfortunately unable to understand from this PR. ❤️

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Dec 16, 2022
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Dec 16, 2022
@ponylang-main
Copy link
Contributor

Hi @jasoncarr0,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 4274.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@jasoncarr0
Copy link
Contributor Author

@mfelsche Ultimately the main point is to avoid infinite loops by identifying when we have already started checking a given goal. This PR does that by pushing the goal into the assumptions earlier than it would be before, so we have it in place before certain recursive calls.

@jasoncarr0 jasoncarr0 force-pushed the subtyping-infinite-loops-fix branch from 7410350 to 2c602b7 Compare December 20, 2022 02:03
Copy link
Member

@jemc jemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me assuming tests pass.

@jasoncarr0 jasoncarr0 marked this pull request as ready for review December 20, 2022 19:01
@jemc jemc removed the do not merge This PR should not be merged at this time label Dec 20, 2022
Copy link
Member

@SeanTAllen SeanTAllen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should be moved to libponyc-run. We don't do "TEST_COMPILE" tests in libponyc tests anymore.

@@ -0,0 +1,14 @@
primitive Foo[T: (Unsigned & UnsignedInteger[T])]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment at the top level of this file explaining in general that this is a compile time check so the "additional cases" are covered because this is compile time, not runtime checking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in f16a0ea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, I added the comment locally, not at the top, is that fine?

@SeanTAllen SeanTAllen merged commit 4c3c4de into main Dec 23, 2022
@SeanTAllen SeanTAllen deleted the subtyping-infinite-loops-fix branch December 23, 2022 23:57
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Dec 23, 2022
github-actions bot pushed a commit that referenced this pull request Dec 23, 2022
github-actions bot pushed a commit that referenced this pull request Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with iftype and generic constraint
5 participants