Merge functions based on partiality rather than Parmatch.irrefutable #1195
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.
translcore.ml
merges together nested functions as long as the parameter is "fluid". This is what gives us a 2 parameter function for things like:but the definition of fluid uses
Parmatch.irrefutable
which does not use type information. So things like:still gives a function of 1 argument returning a function of 1 argument.
Since the partiality of the match (which does use type information) is already available this patch uses it in place of
Parmatch.irrefutable
. I think this is strictly more accurate and safe.Note that there are optimizations in later passes (e.g. simplify) that also attempt to merge functions together. However, these can be quite fragile. For instance, the above case was not merged in 4.03, but this was accidentally fixed in 4.04 for
ocamlopt
by removing some debugging events. An example, which is not merged on trunk isbar
below (unlikefoo
which is always merged):