The check type function now needs to return a std::optional<R> for some type R,
and the check queue overall will return std::nullopt if all individual checks
return that, or one of the non-nullopt values if there is at least one.
For most tests, we use R=int, but for the actual validation code, we make it return
the ScriptError.
https://github.com/bitcoin/bitcoin/pull/31112/commits/1ac1c33f3f120bbe0bde4fa948299bc07cac47ee
Note that there is a minor difference in validation.cpp (`scriptError` vs `error`) because a nearly identical work on improving the error message was done independently by Bitcoin ABC and Bitcoin Core:
- D3811
- core#31097