Remove unneeded explicit calls to std::string

This commit is contained in:
Danila Fedorin 2020-09-18 12:27:57 -07:00
parent 58c6421681
commit 56bdbdc6ee

View File

@ -47,7 +47,7 @@ type_ptr ast_lid::typecheck(type_mgr& mgr, type_env_ptr& env) {
this->env = env; this->env = env;
type_scheme_ptr lid_type = env->lookup(id); type_scheme_ptr lid_type = env->lookup(id);
if(!lid_type) if(!lid_type)
throw type_error(std::string("unknown identifier ") + id, loc); throw type_error("unknown identifier " + id, loc);
return lid_type->instantiate(mgr); return lid_type->instantiate(mgr);
} }
@ -75,7 +75,7 @@ type_ptr ast_uid::typecheck(type_mgr& mgr, type_env_ptr& env) {
this->env = env; this->env = env;
type_scheme_ptr uid_type = env->lookup(id); type_scheme_ptr uid_type = env->lookup(id);
if(!uid_type) if(!uid_type)
throw type_error(std::string("unknown constructor ") + id, loc); throw type_error("unknown constructor " + id, loc);
return uid_type->instantiate(mgr); return uid_type->instantiate(mgr);
} }
@ -105,7 +105,7 @@ type_ptr ast_binop::typecheck(type_mgr& mgr, type_env_ptr& env) {
type_ptr ltype = left->typecheck(mgr, env); type_ptr ltype = left->typecheck(mgr, env);
type_ptr rtype = right->typecheck(mgr, env); type_ptr rtype = right->typecheck(mgr, env);
type_ptr ftype = env->lookup(op_name(op))->instantiate(mgr); type_ptr ftype = env->lookup(op_name(op))->instantiate(mgr);
if(!ftype) throw type_error(std::string("unknown binary operator ") + op_name(op), loc); if(!ftype) throw type_error("unknown binary operator " + op_name(op), loc);
// For better type errors, we first require binary function, // For better type errors, we first require binary function,
// and only then unify each argument. This way, we can // and only then unify each argument. This way, we can
@ -438,7 +438,7 @@ void pattern_constr::find_variables(std::set<std::string>& into) const {
void pattern_constr::typecheck(type_ptr t, type_mgr& mgr, type_env_ptr& env) const { void pattern_constr::typecheck(type_ptr t, type_mgr& mgr, type_env_ptr& env) const {
type_scheme_ptr constructor_type_scheme = env->lookup(constr); type_scheme_ptr constructor_type_scheme = env->lookup(constr);
if(!constructor_type_scheme) { if(!constructor_type_scheme) {
throw type_error(std::string("pattern using unknown constructor ") + constr, loc); throw type_error("pattern using unknown constructor " + constr, loc);
} }
type_ptr constructor_type = constructor_type_scheme->instantiate(mgr); type_ptr constructor_type = constructor_type_scheme->instantiate(mgr);