Only construct zero value of built-in type if the argument count is zero

This commit is contained in:
Nikita Lisitsa 2025-12-23 12:17:18 +03:00
parent 7bca803136
commit 97fb066e38

View file

@ -511,7 +511,16 @@ namespace pslang::interpreter
if (identifier)
{
if (auto type = types::builtin_type(identifier->name))
return zero_value(context, *type);
{
if (function_call.arguments.empty())
return zero_value(context, *type);
std::ostringstream os;
os << "Cannot create built-in type ";
types::print(os, *type);
os << ": expected 0 arguments, but got " << function_call.arguments.size();
throw std::runtime_error(os.str());
}
for (auto it = context.scope_stack.rbegin(); it != context.scope_stack.rend(); ++it)
{