fix #4264

was a type inference bug involving inner functions