fix bug in infer_type