Remove RuntimeError / CompilationError. (#2258)

Instead, work out the prefix for an error based on whether it was produced during parsing, semantic analysis, or when running the program.
This commit is contained in:
Richard Smith
2022-10-04 15:39:04 -07:00
committed by GitHub
parent c703c89658
commit 8f0f69b65f
63 changed files with 254 additions and 264 deletions
+6 -7
View File
@@ -111,8 +111,8 @@ auto ImplScope::ResolveInterface(Nonnull<const InterfaceType*> iface_type,
std::optional<Nonnull<const Witness*>> result,
TryResolve(iface_type, type, source_loc, *this, type_checker));
if (!result.has_value()) {
return CompilationError(source_loc) << "could not find implementation of "
<< *iface_type << " for " << *type;
return ProgramError(source_loc) << "could not find implementation of "
<< *iface_type << " for " << *type;
}
return *result;
}
@@ -133,8 +133,8 @@ auto ImplScope::TryResolve(Nonnull<const InterfaceType*> iface_type,
type_checker));
if (parent_result.has_value()) {
if (result.has_value()) {
return CompilationError(source_loc) << "ambiguous implementations of "
<< *iface_type << " for " << *type;
return ProgramError(source_loc) << "ambiguous implementations of "
<< *iface_type << " for " << *type;
} else {
result = *parent_result;
}
@@ -155,9 +155,8 @@ auto ImplScope::ResolveHere(Nonnull<const InterfaceType*> iface_type,
*iface_type, impl_type, impl, original_scope, source_loc);
if (m.has_value()) {
if (result.has_value()) {
return CompilationError(source_loc)
<< "ambiguous implementations of " << *iface_type << " for "
<< *impl_type;
return ProgramError(source_loc) << "ambiguous implementations of "
<< *iface_type << " for " << *impl_type;
} else {
result = *m;
}