DIRECTOR: Lingo: Process extra or too few arguments for built-ins

This commit is contained in:
Eugene Sandulenko 2016-08-02 10:58:56 +03:00
parent 783ff8f8f2
commit dc498881ef
2 changed files with 15 additions and 0 deletions

View File

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

View File

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