Don't run functions that compile states inside of states, Fix #5623
Merge pull request #6547 from basepi/staterecursion5623

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