Tweak reporting function call type error
This commit is contained in:
parent
d31758eb4a
commit
81825aee7f
1 changed files with 3 additions and 3 deletions
|
|
@ -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]);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue