"They rejoiced in what they had of knowledge," meaning: their knowledge according to themselves, which is their saying: 'We will never be resurrected and we will never be punished.' "And they were encompassed by"—meaning, it became incumbent upon them—"what they used to mock," meaning: the punishment for their mockery.
﴿فَرِحُوا بِمَا عِنْدَهُمْ مِنَ الْعِلْمِ﴾ يَعْنِي: علمهمْ عِنْد أنفسهم هُوَ قَوْلهم لن نبعث وَلنْ نعذب ﴿وحاق بهم﴾ وَجب عَلَيْهِم ﴿مَّا كَانُوا بِهِ يَسْتَهْزِئُون﴾ أَي: عِقَاب استهزائهم.