dworkin / dgd

Dworkin's Game Driver, an object-oriented database management system originally used to run MUDs.
https://www.dworkin.nl/dgd/
GNU Affero General Public License v3.0
103 stars 31 forks source link

Function parameters incorrectly failed by Frame::typecheck() #35

Closed nyankers closed 3 years ago

nyankers commented 3 years ago

With -DCLOSURE enabled, function parameters don't work in some scenarios due to Frame::typecheck() (giving an error message like "Bad object argument 1 for function call" depending of course which parameter receives the function pointer).

I was able to recreate this using a fresh install of cloud-server, with the following two files:

/usr/admin/send.c

mixed sample()
{
    return 42;
}

mixed send_f(function f)
{
    return "caller"->call(f);
}

mixed send_sample()
{
    return send_f(&sample());
}

/usr/admin/caller.c

mixed call(function f)
{
    return (*f)();
}

And logging in as admin, compiling the two objects and running code "send"->send_sample().

It seems to be caused by commit fc3b76ed890290a80690129375006aada7005658 where i_classname(prog_f, sclass) became className(sclass) calling it from the running frame rather than the new frame. Changing this to f->className(sclass) fixed it for me.

dworkin commented 3 years ago

Confirmed and merged, thanks!