Make sure type checked expression has valid type

Fixes bug 696729