-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate remaining exits to FATAL_*_ERROR calls #704
Changes from all commits
4c68c5a
824a737
aa1f601
f375221
9b43d23
9b3525f
9a7f49c
7d39d43
4b562ff
fc2b384
40c23c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,8 +99,7 @@ auto EvalPrim(Operator op, const std::vector<const Value*>& args, int line_num) | |
case Operator::Ptr: | ||
return global_arena->New<PointerType>(args[0]); | ||
case Operator::Deref: | ||
llvm::errs() << line_num << ": dereference not implemented yet\n"; | ||
exit(-1); | ||
FATAL() << "dereference not implemented yet"; | ||
} | ||
} | ||
|
||
|
@@ -298,10 +297,7 @@ auto PatternMatch(const Value* p, const Value* v, Env values, | |
return values; | ||
} | ||
default: | ||
llvm::errs() | ||
<< "internal error, expected a tuple value in pattern, not " << *v | ||
<< "\n"; | ||
exit(-1); | ||
FATAL() << "expected a tuple value in pattern, not " << *v; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an example of why I want to encourage I'm not asking you to make this change; just noting it as an example of the motivation for my other comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted, but I think often we do just want something more like FATAL(), e.g. the previous edit on line 102. |
||
} | ||
case Value::Kind::AlternativeValue: | ||
switch (v->Tag()) { | ||
|
@@ -320,11 +316,7 @@ auto PatternMatch(const Value* p, const Value* v, Env values, | |
return *matches; | ||
} | ||
default: | ||
llvm::errs() | ||
<< "internal error, expected a choice alternative in pattern, " | ||
"not " | ||
<< *v << "\n"; | ||
exit(-1); | ||
FATAL() << "expected a choice alternative in pattern, not " << *v; | ||
} | ||
case Value::Kind::FunctionType: | ||
switch (v->Tag()) { | ||
|
@@ -377,11 +369,7 @@ void PatternAssignment(const Value* pat, const Value* val, int line_num) { | |
break; | ||
} | ||
default: | ||
llvm::errs() | ||
<< "internal error, expected a tuple value on right-hand-side, " | ||
"not " | ||
<< *val << "\n"; | ||
exit(-1); | ||
FATAL() << "expected a tuple value on right-hand-side, not " << *val; | ||
} | ||
break; | ||
} | ||
|
@@ -397,11 +385,7 @@ void PatternAssignment(const Value* pat, const Value* val, int line_num) { | |
break; | ||
} | ||
default: | ||
llvm::errs() | ||
<< "internal error, expected an alternative in left-hand-side, " | ||
"not " | ||
<< *val << "\n"; | ||
exit(-1); | ||
FATAL() << "expected an alternative in left-hand-side, not " << *val; | ||
} | ||
break; | ||
} | ||
|
@@ -428,8 +412,7 @@ void StepLvalue() { | |
CurrentEnv(state).Get(exp->GetIdentifierExpression().name); | ||
if (!pointer) { | ||
FATAL_RUNTIME_ERROR(exp->line_num) | ||
<< ": could not find `" << exp->GetIdentifierExpression().name | ||
<< "`"; | ||
<< "could not find `" << exp->GetIdentifierExpression().name << "`"; | ||
} | ||
const Value* v = global_arena->New<PointerValue>(*pointer); | ||
frame->todo.Pop(); | ||
|
@@ -610,8 +593,7 @@ void StepExp() { | |
CurrentEnv(state).Get(exp->GetIdentifierExpression().name); | ||
if (!pointer) { | ||
FATAL_RUNTIME_ERROR(exp->line_num) | ||
<< ": could not find `" << exp->GetIdentifierExpression().name | ||
<< "`"; | ||
<< "could not find `" << exp->GetIdentifierExpression().name << "`"; | ||
} | ||
const Value* pointee = state->heap.Read(*pointer, exp->line_num); | ||
frame->todo.Pop(1); | ||
|
@@ -670,8 +652,7 @@ void StepExp() { | |
frame->todo.Pop(1); | ||
CallFunction(exp->line_num, act->results, state); | ||
} else { | ||
llvm::errs() << "internal error in handle_value with Call\n"; | ||
exit(-1); | ||
FATAL() << "in handle_value with Call pos " << act->pos; | ||
} | ||
break; | ||
case ExpressionKind::IntTypeLiteral: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth explicitly documenting why you'd want to use this instead of
CHECK(false)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.