Your question doesn't fully investigate Walter's role in the outcome. This is important because US courts play the role of arbiters between parties with specific interests, unlike inquisitorial systems where judges are theoretically impartial. The main fact to consider is that the 5th Amendment has a clause "nor shall be compelled in any criminal case to be a witness against himself" which we understand to mean that you can refuse to testify if the testimony could be used against you in a criminal case – you can "take the Fifth".
If Walter concludes that something he says may be used against him in a criminal case, he has the right to refuse to testify. The courts have repeatedly ruled that an assertion of the right to silence must be clear and unambiguous, not vaguely hinted at. A witness must repeatedly assert that right for each relevant question. One limit on your right to silence is that a defendant has a Sixth Amendment right to cross-examination, so if Walter has testified against the defendant, he cannot invoke the right to silence when the defendant asks questions that challenge his testimony. Walter therefore has to understand the long-term consequences of his testimony, and not say something that will lead him to confessing to a crime under cross-examination.
The government prosecutor can apply to the court for an order of immunity, the consequence of which is that Walter's testimony cannot be used against him in a prosecution. Now Walter must testify or face contempt charges.
A problem is that Walter's testimony must not be false, since the grant of immunity does not immunize against prosecution for perjury in that testimony, see for example US v. Apfelbaum. Walter must therefore testify carefully. Therefore, even with a grant of immunity there is still some risk. Ordinarily the risk is negligible if you just "tell the truth", but Walter cannot assume that the defendant's attorney is also his attorney. As stipulated, Walter is an idiot, and he may not be competent to cleverly frame his response to avoid a perjury charge (e.g. Bronston, Clinton). This can be a problem for Walter if he has limited competence in courtroom English and cannot articulate his personal understanding of the intent of a question (see for example the case in Shuy Language crimes where a witness was convicted for perjury based on his misunderstanding of what the prosecutor was "really asking"). Walter can ask for clarification, and with the assistance of an attorney looking out for Walter's interests could answer the question appropriately.
Walter has to communicate to the judge something about his concern over self-incrimination – he has to first assert the right, before he can be protected.