llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.05k stars 11.98k forks source link

Poor readability of error messages with empty NTTPs #88502

Open mpusz opened 7 months ago

mpusz commented 7 months ago

The following example https://godbolt.org/z/WxshW9nx1 prints plenty of curly braces in the error message:

<source>:18:24: error: no matching function for call to 'time_to_goal'
   18 |   const quantity ttg = time_to_goal(half_marathon_distance, pace);
      |                        ^~~~~~~~~~~~
<source>:9:28: note: candidate template ignored: constraints not satisfied [with distance:auto = quantity<kilo_<metre>{}, double>, speed:auto = quantity<derived_unit<second, per<kilo_<metre>>>{}, double>]
    9 | QuantityOf<isq::time> auto time_to_goal(QuantityOf<isq::length> auto distance, QuantityOf<isq::speed> auto speed)
      |                            ^
<source>:9:80: note: because 'QuantityOf<mp_units::quantity<mp_units::derived_unit<mp_units::si::second, mp_units::per<mp_units::si::kilo_<mp_units::si::metre> > >{{{}}}>, isq::speed>' evaluated to false
    9 | QuantityOf<isq::time> auto time_to_goal(QuantityOf<isq::length> auto distance, QuantityOf<isq::speed> auto speed)
      |                                                                                ^
/opt/compiler-explorer/libs/mp-units/trunk/src/core/include/mp-units/bits/quantity_concepts.h:64:37: note: because 'QuantitySpecOf<std::remove_const_t<decltype(quantity<derived_unit<second, per<kilo_<metre> > >{{{}}}, double>::quantity_spec)>, struct speed{{{}}}>' evaluated to false
   64 | concept QuantityOf = Quantity<Q> && QuantitySpecOf<std::remove_const_t<decltype(Q::quantity_spec)>, QS>;
      |                                     ^
/opt/compiler-explorer/libs/mp-units/trunk/src/core/include/mp-units/bits/quantity_spec_concepts.h:149:73: note: because 'implicitly_convertible(mp_units::kind_of_<mp_units::derived_quantity_spec<mp_units::isq::time, mp_units::per<mp_units::isq::length> > >{}, struct speed{{{}}})' evaluated to false
  149 |   QuantitySpec<T> && QuantitySpec<std::remove_const_t<decltype(QS)>> && implicitly_convertible(T{}, QS) &&
      |                                                                         ^
1 error generated.
Compiler returned: 1

If those curlies could be collapsed into one pair only, the error message would be much more readable.

mpusz commented 7 months ago

One more similar example https://godbolt.org/z/Enarjnsqn.