[x] The goal is to prevent the case where a pass fails (currently with Err(())) but no error is reported (via Diagnostic::error().report) which leads to a failed assertion and a reported internal compiler error in main.
[x] Defined in crate::diagnostic for now as ErrorReported
[x] Ideally, no “plain” constructor but returned by Reporter::report/Diagnostic::report.
However, this won't work with crate::resolver::scope::RegistrationError::DuplicateDefinition which doesn't immediately result in a reported diagnostic by design. Which means we probably need to expose some constructor named sth. like ErrorReported::promise_error_will_be_reported()ErrorReported::error_will_be_reported_unchecked unless we find a way too make this type-safe
[x] Change crate::error's Result definition to default E to ErrorReported instead of ()
[x] Remove the #![allow(clippy::result_unit_err)] in the crate roots as it will no longer be necessary
[x] Require Error variants of possibly erroneous (→ PossiblyErroneous) data to hold/be contstructed with an ErrorReported changing PossiblyErroneous::error to take an _: ErrorReported as an argument. ErrorReported has to impl Clone because AST nodes are Clone but that is not an issue. Discarding is also not a problem right now (since a positive error count leads to a failing exit status even without an ErrorReported (maybe we want to change it making it more strict))
[x] Store ErrorReported in Health::Tainted to be able to make Health and Outcome combinators correct (i.e. remove their calls to ErrorReported::error_will_be_reported_unchecked)
[x] Add documentation to ErrorReported (in #137)
[ ] Bugs in the current implementation
[x] Diagnostic::{warning,debug}().report(reporter) also yields an ErrorReported even though only a warning or debug message, respectively, was issued. ErrorReported should only be obtainable by ::{error, bug}()
[ ] SilentReporter yields a ErrorReported. Instead, it should return () or similar. We can achieve this (I think) by making the Reporter enum a trait and adding an assoc type Output
Heavily inspired by
rustc
.Err(())
) but no error is reported (viaDiagnostic::error().report
) which leads to a failed assertion and a reported internal compiler error inmain
.crate::diagnostic
for now asErrorReported
Reporter::report
/Diagnostic::report
. However, this won't work withcrate::resolver::scope::RegistrationError::DuplicateDefinition
which doesn't immediately result in a reported diagnostic by design. Which means we probably need to expose some constructor named sth. likeErrorReported::promise_error_will_be_reported()
ErrorReported::error_will_be_reported_unchecked
unless we find a way too make this type-safecrate::error
'sResult
definition to defaultE
toErrorReported
instead of()
#![allow(clippy::result_unit_err)
] in the crate roots as it will no longer be necessaryError
variants of possibly erroneous (→PossiblyErroneous
) data to hold/be contstructed with anErrorReported
changingPossiblyErroneous::error
to take an_: ErrorReported
as an argument.ErrorReported
has to implClone
because AST nodes areClone
but that is not an issue. Discarding is also not a problem right now (since a positive error count leads to a failing exit status even without anErrorReported
(maybe we want to change it making it more strict))ErrorReported
inHealth::Tainted
to be able to makeHealth
andOutcome
combinators correct (i.e. remove their calls toErrorReported::error_will_be_reported_unchecked
)ErrorReported
(in #137)Diagnostic::{warning,debug}().report(reporter)
also yields anErrorReported
even though only a warning or debug message, respectively, was issued.ErrorReported
should only be obtainable by::{error, bug}()
SilentReporter
yields aErrorReported
. Instead, it should return()
or similar. We can achieve this (I think) by making theReporter
enum a trait and adding an assoc typeOutput