Tweak reporting function call type error

This commit is contained in:
Nikita Lisitsa 2026-03-26 15:53:06 +03:00
parent d31758eb4a
commit 81825aee7f

View file

@ -542,7 +542,7 @@ namespace pslang::ast
std::string function_name; std::string function_name;
if (auto identifier = std::get_if<ast::identifier>(node.function.get())) if (auto identifier = std::get_if<ast::identifier>(node.function.get()))
function_name = identifier->name + " "; function_name = "\"" + identifier->name + "\" ";
auto function_type = get_type(*node.function); auto function_type = get_type(*node.function);
@ -558,7 +558,7 @@ namespace pslang::ast
if (ftype->arguments.size() != node.arguments.size()) if (ftype->arguments.size() != node.arguments.size())
{ {
std::ostringstream os; std::ostringstream os;
os << "Cannot call function " << function_name << " of type "; os << "Cannot call function " << function_name << "of type ";
print(os, *function_type); print(os, *function_type);
os << ": expected " << ftype->arguments.size() << " arguments, but got " << node.arguments.size(); os << ": expected " << ftype->arguments.size() << " arguments, but got " << node.arguments.size();
throw type_error(os.str(), node.location); throw type_error(os.str(), node.location);
@ -570,7 +570,7 @@ namespace pslang::ast
if (!types::equal(*arg_type, *ftype->arguments[i])) if (!types::equal(*arg_type, *ftype->arguments[i]))
{ {
std::ostringstream os; std::ostringstream os;
os << "Cannot call function " << function_name << " of type "; os << "Cannot call function " << function_name << "of type ";
print(os, *function_type); print(os, *function_type);
os << ": argument #" << i << " expected to have type "; os << ": argument #" << i << " expected to have type ";
print(os, *ftype->arguments[i]); print(os, *ftype->arguments[i]);