Static check for noalloc: better user error #826
Merged
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_dbg
of 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.