“Wayl” (woe) is a word used to warn, scare and threaten people. Seebawayh said: “Wayh” is a word of warning used to alert a person who is about to fall into a dangerous situation, and “wayl” is used for the person who has already fallen into it.
Fath al-Baari, 1/207
Al-Qurtubi (may Allah have mercy on him) said:
The meaning (of the word wayl) is humiliation, punishment and doom.
End quote from al-Jaami‘ li Ahkaam al-Qur’aan, 20/181
Al-Khaazin said: Wayl is a word that the Arabs say to anyone who falls into deep trouble. Its original meaning is punishment and doom.
End quote from Tuhfat al-Ahwadhi, 9/39
Al-Sa‘di (may Allah have mercy on him) said:
Wayl is a comprehensive word that includes all kinds of punishment, grief, torment and fear.
Tafseer al-Sa‘di, p. 813
If a person uses this word deliberately to threaten and warn someone against doing an action that is contrary to sharee‘ah, there is nothing wrong with that. For example, the Prophet (blessings and peace of Allah be upon him) said: “Woe (wayl) to the heels from the Fire! Do wudoo’ properly.” Narrated by al-Bukhaari, 96; Muslim, 241.
If a person uses this word for everything that he thinks is different to what he thinks, even if the issue is a matter of controversy among the scholars, or he uses it for something that is contrary to a Sunnah, such as saying, “Woe (wayl) to the one who does not recite Soorat al-Faatihah behind the imam” or “Woe (wayl) to the one who does not offer the Sunnah prayer of Maghrib,” this is not permissible.
If a person says it deliberately, praying against himself, that is not permissible, unless he says it in a way that is connected to a condition, such as if he says, “Woe to me (ya wayli) from the punishment of Allah if He does not forgive me,” as ‘Umar (may Allah be pleased with him) said when he was stabbed: “Woe to me and woe to my mother if I am not forgiven.”
Narrated by Imam Ahmad in al-Zuhd, p. 125
With regard to the view of the one who says that it erases the good deeds that came before it, this is not correct because there is no evidence for that.
If a person says it deliberately or otherwise in an inappropriate manner in which it is not permissible to say it, he has to ask Allah for forgiveness and not do it again.
And Allah knows best.