mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 22:02:33 +01:00
Switch executable semantics to use ErrorBuilder directly and relocate macros (#1184)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user