ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.21k stars 348 forks source link

Don't display undefined variable warnings when evaluating the `?` operator #5983

Closed dra27 closed 1 month ago

dra27 commented 1 month ago

2921 added the ? operator to allow filters to have expressions like ?foo & foo = "foo", where ?foo is true if and only if foo 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 https://github.com/ocaml/opam-repository/pull/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 the post 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.

kit-ty-kate commented 1 month ago

Thanks!