Commentary for Avodah Zarah 40:9
ת"ר (דברים כג, י) ונשמרת מכל דבר רע שלא יהרהר אדם ביום ויבוא לידי טומאה בלילה
Our Rabbis taught: “Guard yourself from all evil things” (Deuteronomy 23:10), this means that one should not think [sexual] thoughts during the day that would to uncleanliness by night.
Daf Shevui to Avodah Zarah
This is another midrash on the verse from Deuteronomy. A person should strive for holiness, which here seems to be defined as avoiding what we might term “sexual pollution,” and may be an allusion to wet dreams.
Ask RabbiBookmarkShareCopy