Env: Fix function argument size error message

This commit is contained in:
Riyyi
2023-04-07 23:38:41 +02:00
parent 6e1557ff8c
commit f35fea9fa4
+7 -3
View File
@@ -134,7 +134,7 @@ ADD_FUNCTION(
bool result = true; \ bool result = true; \
\ \
if (nodes.size() < 2) { \ if (nodes.size() < 2) { \
Error::the().add(format("wrong number of arguments: {}, {}", #operator, nodes.size() - 1)); \ Error::the().add(format("wrong number of arguments: {}, {}", #operator, nodes.size())); \
return nullptr; \ return nullptr; \
} \ } \
\ \
@@ -185,6 +185,10 @@ ADD_FUNCTION(
{ {
bool result = true; bool result = true;
if (nodes.size() == 0) {
result = false;
}
for (auto node : nodes) { for (auto node : nodes) {
if (!is<List>(node.get())) { if (!is<List>(node.get())) {
result = false; result = false;
@@ -219,7 +223,7 @@ ADD_FUNCTION(
"count", "count",
{ {
if (nodes.size() != 1) { if (nodes.size() != 1) {
Error::the().add(format("wrong number of arguments: count, {}", nodes.size() - 1)); Error::the().add(format("wrong number of arguments: count, {}", nodes.size()));
return nullptr; return nullptr;
} }
@@ -286,7 +290,7 @@ ADD_FUNCTION(
"=", "=",
{ {
if (nodes.size() < 2) { if (nodes.size() < 2) {
Error::the().add(format("wrong number of arguments: =, {}", nodes.size() - 1)); Error::the().add(format("wrong number of arguments: =, {}", nodes.size()));
return nullptr; return nullptr;
} }