Eating forgetfully or by mistake
The Prophet (sal Allahu alaihi wa sallam) said: “Whoever forgets he is fasting and eats or drinks, let him complete his fast for it is Allah Who has fed him and given him to drink.”
[Sahih al-Bukhari and Muslim]
Another narration informs us that the fasting person who eats or drinks by mistake does not have to offer expiation or make up that fast.
Abu Hurayrah (radi Allahu anhu) said that the Prophet (sal Allahu alaihi wa sallam) said, “Whoever breaks his fast in Ramadan by mistake does not have to make up that day or offer expiation.” [Ibn Khuzaymah (1999) - Classed as Hasan by Shaykh al-Albaani in Sahih Ibn Khuzaymah]
The majority of scholars quote these ahadith as evidence that whoever forgets that he is fasting and breaks the fast, his fast is still valid, and he should complete his fast, and he does not have to make it up or offer any expiation. The general meaning of the Hadith covers both obligatory and naafil (voluntary) fasts; there is no difference between the two.
Imam Al-Shaafa’i (may Allah have mercy upon him) said in ‘al-Umm’: If a fasting person eats or drinks in Ramadan or in a fast observed in fulfilment of a vow or as an expiation, or a fast that is obligatory for some reason, or a voluntary fast, out of forgetfulness, then his fast is complete and he does not have to make it up.
Imam Al-Nawawi (may Allah have mercy upon him) said: This is evidence to support the view of the majority: if the fasting person eats or drinks or has intercourse because of forgetfulness, then he does not break his fast. Among those who were of this view are al-Shaafa’i, Abu Haneefah, Dawood and others.
Al-Haafiz ibn Hajr (may Allah have mercy upon him) said: An interesting story was narrated by ‘Abd al-Razzaaq from ‘Amr ibn Dinar that a person came to Abu Hurayrah (radi Allahu anhu) and said, “I started fasting in the morning then I forgot and ate.” He (radi Allahu anhu) said, “It does not matter.” He said: “Then I entered upon someone and by mistake I ate and drank.” He (radi Allahu anhu) said, “It does not matter, Allah has fed you and given you to drink.” Then he said: “I entered upon another person and forgot, and ate.” Abu Hurayrah (radi Allahu anhu) said: “You are a person who is not used to fasting.”
And Allah knows best!