Static check for noalloc: better user error#826
Merged
gretay-js merged 3 commits intooxcaml:mainfrom Oct 4, 2022
Merged
Conversation
xclerc
reviewed
Sep 13, 2022
7c1babb to
8853289
Compare
8853289 to
25e27c5
Compare
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.
On top of #825 - only the last two commits are new.
Print the source location of the function in the user error message when the
[@assert noalloc]annotation on the function fails with -alloc-check flag.The message is still not great: the debug info points to the function (not the annotation) because that's what we have in the backend. Perhaps we can carry around the location (or Debuginfo.t) along with the attribute, as part of Lambda.check_attribute, but it's not done for anything else of this sort, and seems not worth it (code complexity and memory footprint).
As it is, the check will already hold on to all the
fun_dbgof the entire compilation unit until the end. If this becomes a problem, we can try checking annotations earlier, instead of waiting until the end of the compilation unit, but somethings cannot be resolved until the end.