Flambda2 layouts: Fix partial application wrapper result arity #1551
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue where an incorrect result arity on a partial application wrapper will trip a couple asserts in flambda2 (and would generate incorrect code without the asserts). The basic issue is two places where the result arity of a partial application (which is always value) is incorrectly used as the result arity of the fully applied version after wrapping (which might not be value).
I don't think this error can be observed on the current main branch because you need alternate layouts. But I can see it in #1528 on programs like this:
Both places are in
Closure_conversion.wrap_partial_application
- the rest of this is just plumbing to get the correct result arity to that function.I haven't added a test here because I'm not sure it's possible without another layout, but I have tested applying this diff to #1528, which gets the tests to pass on flambda2 on my machine. I've just pushed it there and we'll see if the CI validates that.