aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/director/lingo/lingo-code.cpp13
-rw-r--r--engines/director/lingo/tests/math.lingo2
2 files changed, 15 insertions, 0 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 7b367d9720..344fbc2885 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -702,7 +702,20 @@ void Lingo::c_call() {
Symbol *sym = g_lingo->_handlers[name];
+ if (sym->nargs < nargs) {
+ warning("Incorrect number of arguments for function %s. Dropping extra %d", name.c_str(), nargs - sym->nargs);
+ for (int i = 0; i < nargs - sym->nargs; i++)
+ g_lingo->pop();
+ }
+
if (sym->type == BLTIN) {
+ if (sym->nargs > 0 && nargs < sym->nargs) {
+ warning("Too few arguments for function %s. Expecting %d but got %d", name.c_str(), sym->nargs, nargs);
+ for (int i = 0; i < nargs; i++)
+ g_lingo->pop();
+
+ return;
+ }
(*sym->u.func)();
return;
diff --git a/engines/director/lingo/tests/math.lingo b/engines/director/lingo/tests/math.lingo
index 9c0b2d57a3..6f8ecc374f 100644
--- a/engines/director/lingo/tests/math.lingo
+++ b/engines/director/lingo/tests/math.lingo
@@ -12,6 +12,8 @@ set x = 2 + 3 * (4 / 2)
put x
put power(2, 8)
+put power(2, 8, 0)
+put power(2)
updatestage
-- Type conversion