@@ -15,7 +15,7 @@ class ErrorBase {
1515 public:
1616 bool operator ==(const ErrorBase& other) const { return error_string () == other.error_string (); }
1717 virtual StringView error_string () const = 0;
18- virtual ~ErrorBase () = default ;
18+ virtual ~ErrorBase () = default ;
1919};
2020class Error : public ErrorBase {
2121 protected:
@@ -113,7 +113,6 @@ class Result {
113113 Result (OtherET&& val)
114114 requires (DerivedFrom<OtherET, ErrorBase>)
115115 : m_err{ new OtherET{ move (val) } }, m_type{ CurrType::Err } {}
116-
117116 // the following overloads may look very confusing
118117 // which is why they're commented
119118
@@ -126,7 +125,6 @@ class Result {
126125 Result (UniquePtr<OtherET>&& err) : m_type{ CurrType::Err } {
127126 new (&m_err) UniquePtr<ErrorBase>{ err.release () };
128127 }
129-
130128 // this overload activates when OtherET can be converted to ErrorType
131129 // *but* is not a derived type, this means that we don't care about object slicing
132130 // and we should instead just create a new error.
@@ -135,7 +133,6 @@ class Result {
135133 Result (UniquePtr<OtherET>&& err) : m_type{ CurrType::Err } {
136134 new (&m_err) UniquePtr<ErrorBase>{ new ErrorType{ move (*err) } };
137135 }
138-
139136 // this overload activates when OtherET is unrelated to ErrorType but the IntoError "interface"
140137 // can be used to convert from a type to the other
141138 template <typename OtherET>
@@ -295,9 +292,10 @@ class Result {
295292 }
296293 auto must () {
297294 if (is_error ()) {
298- ASSERT_NOT_REACHED_FMT (
299- " %s::must() failed \" %s\" " , TYPENAME_TO_STRING (*this ), print_conditional (to_error ()).data ()
300- );
295+ with_type_of (*this , [&](const char * name) {
296+ String error_name = print_conditional (to_error ());
297+ ASSERT_NOT_REACHED_FMT (" %s::must() failed \" %s\" " , name, error_name.data ());
298+ });
301299 }
302300 return to_ok ();
303301 }
@@ -356,11 +354,9 @@ struct PrintInfo<Result<T, Err>> {
356354
357355#define TRY_SET (val, expression ) TRY_SET_IMPL(val, CONCAT_TOKENS(__tr_, __COUNTER__), expression)
358356
359- #define TRY_RET (expression ) \
360- { TRY_RET_IMPL (CONCAT_TOKENS (__tr_, __COUNTER__), expression) }
357+ #define TRY_RET (expression ) { TRY_RET_IMPL (CONCAT_TOKENS (__tr_, __COUNTER__), expression) }
361358
362- #define TRY (expression ) \
363- { TRY_IMPL (CONCAT_TOKENS (__tr_, __COUNTER__), expression) }
359+ #define TRY (expression ) { TRY_IMPL (CONCAT_TOKENS (__tr_, __COUNTER__), expression) }
364360
365361#define MUST (expression ) \
366362 [](auto && tr) { \
0 commit comments