Check return modes in type_argument after eliminating optionals#734
Closed
stedolan wants to merge 1 commit intooxcaml:mainfrom
Closed
Check return modes in type_argument after eliminating optionals#734stedolan wants to merge 1 commit intooxcaml:mainfrom
stedolan wants to merge 1 commit intooxcaml:mainfrom
Conversation
Contributor
Author
|
Closed in favour of the better fix in #735 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There is a missing mode check in
type_argument, in the case where it eliminates one or more optional arguments. With the following declarations in scope:then the expression
use mklocalcurrently compiles without error, ignoring thelocal_return mode. This patch makesuse mklocalan error, by checking that the return mode matches the expected mode.I suspect that this has been unsound for a while, but it is difficult to make it segfault. (Since
type_argumenteta-expands, the obvious approach works without error). However, the bug causes the application inside type_argument's eta-expansion to have the wrong mode, which interacts badly with the mode-specificcaml_curryandcaml_applyfunctions.The bug became much easier to trigger after ocaml-flambda/ocaml-jst#24, and showed up in real code, from which the testsuite example is extracted. I haven't managed to construct an example that segfaults before 24, but I think one probably exists.