Fixed a stack overflow when reaching the end of the expression