mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Add a FatalUserError macro to help print user-caused errors. (#668)
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "executable_semantics/ast/function_definition.h"
|
||||
#include "executable_semantics/common/error.h"
|
||||
#include "executable_semantics/common/tracing_flag.h"
|
||||
#include "executable_semantics/interpreter/interpreter.h"
|
||||
|
||||
@@ -19,20 +20,18 @@ namespace Carbon {
|
||||
void ExpectType(int line_num, const std::string& context, const Value* expected,
|
||||
const Value* actual) {
|
||||
if (!TypeEqual(expected, actual)) {
|
||||
llvm::errs() << line_num << ": type error in " << context << "\n"
|
||||
<< "expected: " << *expected << "\n"
|
||||
<< "actual: " << *actual << "\n";
|
||||
exit(-1);
|
||||
FatalUserError() << line_num << ": type error in " << context << "\n"
|
||||
<< "expected: " << *expected << "\n"
|
||||
<< "actual: " << *actual;
|
||||
}
|
||||
}
|
||||
|
||||
void ExpectPointerType(int line_num, const std::string& context,
|
||||
const Value* actual) {
|
||||
if (actual->tag() != ValKind::PointerType) {
|
||||
llvm::errs() << line_num << ": type error in " << context << "\n"
|
||||
<< "expected a pointer type\n"
|
||||
<< "actual: " << *actual << "\n";
|
||||
exit(-1);
|
||||
FatalUserError() << line_num << ": type error in " << context << "\n"
|
||||
<< "expected a pointer type\n"
|
||||
<< "actual: " << *actual;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user