Declaration of `type_num` needs to be moved to the top.