Don't display undefined variable warnings when evaluating the ?
operator
#5983
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.
#2921 added the
?
operator to allow filters to have expressions like?foo & foo = "foo"
, where?foo
is true if and only iffoo
is a defined variable (or an expression where all the variables have been successfully resolved).However, it doesn't seem to have been working, which I'd spotted in the ocaml-system updates in ocaml/opam-repository#25861. Unfortunately, the failure means that the repository can't be used with
--strict
.The fundamental problem is that the warning about undefined variables is displayed when the variables are being resolved, which sadly includes the moment they are being tested with the
?
operator. However, when a filter is partially evaluated, the resulting filter will only contain undefined variables (and thepost
variable), which allows the check added in #5141 to be co-opted to display the unresolved variables after the filter has been reduced, rather than during the reducing.