Fix circular global/function dependency

The problem happens when the type of a global depends on the return type of a function, which depends on the type of the global