Fix type inference for proc expressions

Fix #10718.