Extract common code for making sure sub-statements are type checked