-
-
Notifications
You must be signed in to change notification settings - Fork 418
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 tuple related compiler segfaults #3723
Conversation
It's possible that the method body returns a subtype of the return type. For example, a return value with type `((U32, U32) | (U32, None))` is legal for a method with return type `(U32, (U32 | None))`, but it requires a cast. Fixes ponylang#2609, ponylang#2808
@Trundle on a roll! |
Hi @Trundle, 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 The basic format of the release notes (using markdown) should be:
Thanks. |
Confirmed that #2808 is fixed by this. |
Confirmed #2609 is fixed. |
I'll hold tomorrow's ponyc release until this has release notes and is merged. Thanks @Trundle. |
@Trundle I think "Fix tuple related compiler segfaults" would be a good release notes title. |
I've added release notes. |
Thank you for adding the release notes, @SeanTAllen. They contain a slight mistake though: the crash happens in the compiled code, not the compiler itself. Is it worth fixing and if so, how does it work? Should I open a new PR with changes to |
@Trundle yeah go ahead and then I'll update the release page as well. |
It's possible that the method body returns a subtype of the return type.
For example, a return value with type
((U32, U32) | (U32, None))
islegal for a method with return type
(U32, (U32 | None))
, but itrequires a cast.
071db10 changed that methods returning a tuple always use a cast as if the method body's value already has the return type. Unfortunately, it doesn't go into detail why. This already caused an issue in #849 and an exception was added if return type and body type are both tuples. I think that assumption doesn't hold: for the above mentioned case, the return type is a tuple, but the body type is an union, and yet the current code continues as if the body produces a tuple.
Fixes #2609, #2808