The dead is punished because of the lamentation of the living. Upon this 'A'isha said: May Allah have mercy upon the father of 'Abd al-Rahman (Ibn 'Umar). He did not tell a lie, but he forgot or made a mistake. The Messenger of Allah ﷺ happened to pass by a (dead) Jewess who was being lamented. Upon this he said: They weep over her and she is being punished in the grave. (Using translation from Muslim 932c)
عَائِشَةُ يَغْفِرُ اللهُ لِأَبِي عَبْدِ الرَّحْمَنِ أَمَا إِنَّهُ لَمْ يَكْذِبْ وَلَكِنَّهُ نَسِيَ أَوْ أَخْطَأَ إِنَّمَا مَرَّ رَسُولُ اللهِ ﷺ عَلَى يَهُودِيَّةٍ يُبْكَى عَلَيْهَا فَقَالَ «إِنَّهُمْ لَيَبْكُونَ عَلَيْهَا وَإِنَّهَا لَتُعَذَّبُ»