A Hugo incarnation of the blog. https://danilafe.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
940 B

#include "error.hpp"
const char* type_error::what() const noexcept {
return "an error occured while checking the types of the program";
}
void type_error::pretty_print(std::ostream& to, parse_driver& drv) {
to << "encountered error while typechecking program: ";
to << description << std::endl;
if(loc) {
to << "occuring on line " << loc->begin.line << ":" << std::endl;
to << std::endl << "```" << std::endl;
drv.print_highlighted_location(to, *loc);
to << "```" << std::endl << std::endl;
}
}
void unification_error::pretty_print(std::ostream& to, parse_driver& drv, type_mgr& mgr) {
type_error::pretty_print(to, drv);
to << "the expected type was:" << std::endl;
to << " \033[34m";
left->print(mgr, to);
to << std::endl << "\033[0mwhile the actual type was:" << std::endl;
to << " \033[32m";
right->print(mgr, to);
to << "\033[0m" << std::endl;
}