Estaba leyendo documentación de solidez sobre cuándo se genera una excepción de estilo de aserción. En el punto 6 dice:
"Si llama a una variable inicializada en cero del tipo de función interna".
no lo entiendo ¿Puede alguien darme un ejemplo?
Las variables pueden contener punteros de función. Si los deja sin inicializar y luego intenta llamarlos, la llamada fallará porque la variable se inicializó en cero y, por lo tanto, no contiene un puntero a una función invocable. Ejemplo:
function b(int x, int y) internal pure returns (int)
{
return x * y;
}
function test1() external pure returns (int)
{
// Variable containing a function pointer
function (int, int) internal pure returns (int) funcPtr;
funcPtr = b;
// This call to funcPtr will succeed
return funcPtr(4, 5);
}
function test2() external pure returns (int)
{
// Variable containing a function pointer
function (int, int) internal pure returns (int) funcPtr;
// This call will fail because funcPtr is still a zero-initialized function pointer
return funcPtr(4, 5);
}