Add locations to error reporting.

This commit is contained in:
2020-09-09 15:08:43 -07:00
parent 2fa2be4b9e
commit aa867b2e5f
3 changed files with 40 additions and 13 deletions

View File

@@ -144,8 +144,9 @@ int main(int argc, char** argv) {
std::cout << def_defn.second->name;
for(auto& param : def_defn.second->params) std::cout << " " << param;
std::cout << ":" << std::endl;
def_defn.second->body->print(1, std::cout);
std::cout << std::endl;
}
try {
typecheck_program(driver.global_defs, mgr, env);
@@ -153,14 +154,8 @@ int main(int argc, char** argv) {
scope.compile();
gen_llvm(scope);
} catch(unification_error& err) {
std::cout << "failed to unify types: " << std::endl;
std::cout << " (1) \033[34m";
err.left->print(mgr, std::cout);
std::cout << "\033[0m" << std::endl;
std::cout << " (2) \033[32m";
err.right->print(mgr, std::cout);
std::cout << "\033[0m" << std::endl;
err.pretty_print(std::cout, driver, mgr);
} catch(type_error& err) {
std::cout << "failed to type check program: " << err.description << std::endl;
err.pretty_print(std::cout, driver);
}
}