extracted from inp_fix_inst_calls_for_numparam(). This code is and was evil, as it does not respect scoping rules.