Passing a delegate by value to a vararg parameter causes a crash.
The following code causes the crash in 2.31.1:
funcdef void Foo();
class Bar
{
void bar()
{
Print( "works\n" );
}
}
void test()
{
dictionary foo;
foo.set( "bar", Foo( Bar().bar ) );
Foo@ pFoo;
foo.get( "bar", @pFoo );
pFoo();
}
dictionary::set's second parameter is ?& in, which fails to handle this case. Using @Foo instead of Foo causes it to work as expected.
A complete program that triggers this problem can be downloaded here: https://dl.dropboxusercontent.com/u/46048979/AS_FuncDefBug.rar
Generic functions taking ref objects for vararg parameters are a bit hard to deal with. Seems like they sometimes have their ref count incremented by the engine, but not always. Sometimes i'd double free one, and if i don't, i end up leaking a reference. Seems to be related to this problem.