Don't run functions that compile states inside of states, Fix #5623