Fix infinite recursion in type checker on recursive items

Recursive items are currently detected in the `check_const` pass which runs after type checking.  This means a recursive static item used as an array length will cause type checking to blow the stack.  This PR separates the recursion check out into a separate pass which is run before type checking.

Closes issue #17252

r? @nick29581
check_const_recursion  is probably better - rec is not clear. (Could also be check_static_recursion since we only check statics, not all const exprs)