When capturing en passant, is a position possible such that there is a pin over the square of the taken pawn, rather than the taking pawn? 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)?
Really interesting question. I think the following shows that such a situation is sort of possible, depending on how you define the pin.
[StartFlipped &quot;0&quot;]
[FEN &quot;7k/4p3/8/2KP3r/8/8/8/8 b - - 0 1&quot;]

1... e5 2. dxe6?! {Illegal move!}

Now, 2. dxe6 is illegal. The check would go from being stopped by both pawns, to being stopped by neither.