Browse Source

Eval: Add error message for invalid function calls

master
Riyyi 2 years ago
parent
commit
6c12b199e8
  1. 3
      src/eval.cpp

3
src/eval.cpp

@ -42,7 +42,7 @@ ASTNode* Eval::evalAst(ASTNode* ast, Environment* env)
if (is<Symbol>(ast)) { if (is<Symbol>(ast)) {
auto result = env->lookup(static_cast<Symbol*>(ast)->symbol()); auto result = env->lookup(static_cast<Symbol*>(ast)->symbol());
if (!result) { if (!result) {
Error::the().addError(format("'{}' not found", ast)); Error::the().addError(format("symbol’s function definition is void: {}", ast));
} }
return result; return result;
} }
@ -79,6 +79,7 @@ ASTNode* Eval::apply(List* evaluated_list)
auto nodes = evaluated_list->nodes(); auto nodes = evaluated_list->nodes();
if (!is<Function>(nodes[0])) { if (!is<Function>(nodes[0])) {
Error::the().addError(format("invalid function: {}", nodes[0]));
return nullptr; return nullptr;
} }

Loading…
Cancel
Save