[SERVER-80409] [CQF] Improve compile-time error messages of PolyValue, algebra::transport Created: 24/Aug/23  Updated: 20/Nov/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: David Percy Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-76921 toolchain v4 clang-format unaware of ... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

When you call a template function with the wrong arguments, the default error message points to the implementation of the template, and buries the true problem in a list of "required from here" / "included from here" notes.

In C++20 we can use concepts and 'requires' clauses to improve these error messages. For example, if we add this clause:

    template <typename T, typename... Args>
    requires(std::constructible_from<T, Args...>)
    static PolyValue make(Args&&... args) {
        return PolyValue{ControlBlockVTable<T, Ts...>::make(std::forward<Args>(args)...)};
    }

then a misuse like ABT::make<Variable>(5) would be caught at the call site, instead of in polyvalue.h.

Another good candidate is algebra::transport. Specifying its requirements is probably harder because its interface has many different options. But that complex interface is also why improving its error messages would be so useful.


Generated at Thu Feb 08 06:43:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.