I am trying to write a simple chess program, and as part of this I am writing methods to find all valid moves. I can detect pins and have no trouble leaving out the moves that would result in the moving player being in check, except for one situation I am not sure about.
After an en passant capture, not only is the square previously occupied by the capturing pawn now vacant, but so is the square of the captured pawn. Is there any position at all where capturing en passant results in a discovered check on the king of the player that is capturing en passant, not because the capturing pawn was pinned, but because the check was previously stopped by the captured pawn?
I think this situation is simply not possible, at the very least I can't think of a position and series of moves that results in this situation; the fact that you have to capture en passant at the first opportunity means that either the pawn that should later capture en passant is pinned and can't advance to the fifth rank, or the check is blocked by a different piece anyway. Unfortunately I am having trouble ruling out there is some counter-intuitive position where this might happen. Could someone confirm my suspicions (or provide a counter-example)?