Improve ARRAY-RANK transform.

* Don't crash on bad types.
* Delay the transform if the type isn't yet known.

Fixes lp#1252108.