Fixes #917. This PR goes along with #3816 to enable support for `notany()` and `context()` references from the output.