Switch executable semantics to use ErrorBuilder directly and relocate macros (#1184)

This commit is contained in:
Jon Meow
2022-04-13 09:05:21 -07:00
committed by GitHub
parent 6542506cdc
commit 87e58f5db3
37 changed files with 327 additions and 376 deletions
+4 -5
View File
@@ -4,7 +4,7 @@
#include "executable_semantics/ast/static_scope.h"
#include "executable_semantics/common/error.h"
#include "executable_semantics/common/error_builders.h"
#include "llvm/Support/Error.h"
namespace Carbon {
@@ -13,7 +13,7 @@ auto StaticScope::Add(std::string name, ValueNodeView entity)
-> ErrorOr<Success> {
auto [it, success] = declared_names_.insert({name, entity});
if (!success && it->second != entity) {
return FATAL_COMPILATION_ERROR(entity.base().source_loc())
return CompilationError(entity.base().source_loc())
<< "Duplicate name `" << name << "` also found at "
<< it->second.base().source_loc();
}
@@ -26,8 +26,7 @@ auto StaticScope::Resolve(const std::string& name,
ASSIGN_OR_RETURN(std::optional<ValueNodeView> result,
TryResolve(name, source_loc));
if (!result) {
return FATAL_COMPILATION_ERROR(source_loc)
<< "could not resolve '" << name << "'";
return CompilationError(source_loc) << "could not resolve '" << name << "'";
}
return *result;
}
@@ -45,7 +44,7 @@ auto StaticScope::TryResolve(const std::string& name,
parent->TryResolve(name, source_loc));
if (parent_result.has_value() && result.has_value() &&
*parent_result != *result) {
return FATAL_COMPILATION_ERROR(source_loc)
return CompilationError(source_loc)
<< "'" << name << "' is ambiguous between "
<< result->base().source_loc() << " and "
<< parent_result->base().source_loc();