In AngelScript 2.31.1 WIP revision 2319, the following code causes an assertion failure, and if ignored, an access violation error:
funcdef bool Callback(int, int);
bool myGreaterThan(int a, int b) {
return a > b;
}
bool myEquals(int a, int b) {
return a == b;
}
bool myLessThan(int a, int b) {
return a < b;
}
dictionary ops = {
{"gt", @myGreaterThan},
{"lt", @myLessThan},
{"eq", @myEquals}
};
This error is exclusive to the $func type, i.e. won't occur if myCompare, myLessThan, and myEquals are assigned to handles of type Callback first and then those handles are passed to the initialization list. To remedy this temporarily script-side, I attempted making the following change to the ops definition:
dictionary ops = {
{"gt", cast<Callback>(myGreaterThan)},
{"lt", cast<Callback>(myLessThan)},
{"eq", cast<Callback>(myEquals)}
};
This causes a different access violation without ever triggering an assertion failure. I didn't test whether the bugs are exclusive to initialization lists or also occur for generic function arguments.