-
Notifications
You must be signed in to change notification settings - Fork 63
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 function return layout bug #2471
Conversation
As discussed, my original attempt at a fix was clearly and painfully wrong (hence the test failures): I was calling I've pushed an updated attempt:
Two internal-only tests' outputs get worse in a way that doesn't seem easy to fix. The location reported by the error is now the function cases' location rather than the location of the case body that has the void layout. But the whole point of this PR is to use the cases as a whole to determine the return layout rather than focusing on just one case's body. |
@goldfirere Could you please provide another round of review given the changes? |
@Ekdohibs please review the trivial changes to chamelon. (This is waiting on Richard's review too but I suspect the changes to chamelon will be affected at most in uninteresting ways by his review.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For chamelon/
changes.
As I've commnuicated to Nick directly, I'm still a little surprised at the shape of this patch and believe that there may be a better way. We had scheduled a meeting to discuss, but I'm now unable to make that meeting. Let's merge this, and Nick and I will (briefly) revisit when I'm back. (I would merge myself, but perhaps there's been some development I'm not yet read up on, and so I will leave it to Nick to merge.) |
I'm merging now. I'll wait to upstream this fix until Richard and I have had a chance to meet. I will open an issue upstream, though, in case this impacts the release cycle at all. |
Just to record what Richard and I discussed:
|
#1817 introduced a bug where
translcore
computed a function's return layout according only to its first case if it was written with thefunction
syntax. This PR fixes that bug by computing the return layout the same way it was computed prior to #1817.For example, the function
get
would get a return layout ofPvalue Pintval
even though a float is returned out of the second case:You can turn this into a flambda2 middle-end crash. (I haven't been able to turn it into a miscompilation, but I theorize this is possible.) This PR adds the crashing test as a regression test.
The same bug exists upstream; I'll post the corresponding PR there after this is reviewed.