This is an artificial issue, creating an unenforceable rule, stress for students, etc. The teacher should create a situation in which people have enough information about prior exams to (rightly) feel that they have an idea what will be on the upcoming exam. And if two exams are given at two times, they should not be identical, certainly. It should be arranged that students in the later exam should find nothing surprising or particularly in formative in seeing the first exam. That is, the marginal information content of seeing the first-given exam, with all prior exams visible, for example, should be close to zero.
Edit: it is never genuinely wrong for students to get information about past exams. It is not the obligation of students to "refuse" to give information about exams they have taken. It is not the obligation of students to "not ask" students who've already taken exams about their content. Students should be allowed to behave sensibly. It is, instead, the obligation (if any) of their teachers to create contexts in which the students do not have to worry about artificial (and extremely awkward) constraints on information.
Unenforceable rules create stress, trouble, and fatigue, to no good purpose. Students shouldn't have to think in such terms.