fix returned value's type according to given value's type