Browse Source

Env: Fix function argument size error message

master
Riyyi 1 year ago
parent
commit
f35fea9fa4
  1. 10
      src/functions.cpp

10
src/functions.cpp

@ -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;
} }

Loading…
Cancel
Save