Closes #6312. In the C++ implementation this caused a stack overflow from infinite recursion during analysis.