There is code:
class TestDeleteDelegate {
uint k = 0;
~TestDeleteDelegate() {
Print("~TestDeleteDelegate");
}
void func() {
Print("func " + k);
}
};
funcdef void vv();
vv@ funcRef;
void testDelDelegate() {
TestDeleteDelegate tdd;
tdd.k = 10;
@funcRef = vv(tdd.func);
}
int main() {
testDelDelegate();
funcRef();
return 0;
}
When I run this and call module→Discard, I get output:
func 10
~TestDeleteDelegate
>>> warning: There is an external reference to an object in module 'test', preventing it from being deleted
>>> warning: The function in previous message is named 'main'. The func type is 1
>>> warning: There is an external reference to an object in module 'test', preventing it from being deleted
>>> warning: The function in previous message is named '~TestDeleteDelegate'. The func type is 1
>>> warning: There is an external reference to an object in module 'test', preventing it from being deleted
>>> warning: The builtin type in previous message is named 'TestDeleteDelegate'
Why references not cleared correctly on discard module?