Anas ibn Malik, may Allah be pleased with him, said, “The Messenger of Allaah, peace and blessings of Allaah be upon him, said:
“If any one of you feels sleepy when he is praying, he should sleep until he [is rested enough to] know what he is saying.” (Reported by al-Bukhaari, no. 210)
This may happen when one is praying qiyaam al-layl, at the time when prayers are answered, and a person may pray against themselves without realizing it. This hadeeth also includes fard or obligatory prayers, when a person is confident that they will still have enough time to pray after taking a nap. (Fath al-Baari, Sharh Kitaab al-Wudoo’, Baab al-wudoo’ min al-nawm).