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
@@ -15,7 +15,7 @@
#include "executable_semantics/ast/declaration.h"
#include "executable_semantics/ast/expression.h"
#include "executable_semantics/common/arena.h"
#include "executable_semantics/common/error.h"
#include "executable_semantics/common/error_builders.h"
#include "executable_semantics/interpreter/action.h"
#include "executable_semantics/interpreter/action_stack.h"
#include "executable_semantics/interpreter/stack.h"
@@ -560,7 +560,7 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
const auto& tuple = cast<TupleValue>(*act.results()[0]);
int i = cast<IntValue>(*act.results()[1]).value();
if (i < 0 || i >= static_cast<int>(tuple.elements().size())) {
return FATAL_RUNTIME_ERROR_NO_LINE()
return RuntimeError(exp.source_loc())
<< "index " << i << " out of range in " << tuple;
}
return todo_.FinishAction(tuple.elements()[i]);
@@ -813,7 +813,7 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
}
}
default:
return FATAL_RUNTIME_ERROR(exp.source_loc())
return RuntimeError(exp.source_loc())
<< "in call, expected a function, not " << *act.results()[0];
}
} else if (act.pos() == 3) {