"And moreover, behold, she is with child by harlotry" (Genesis 38:24). Ulla said: Tamar committed harlotry and Zimri committed harlotry. From Tamar, who committed harlotry, there came forth kings and prophets; through Zimri, who committed harlotry, many tens of thousands of Israel fell. "And moreover, behold, she is with child by harlotry" [teaches] that she would enter the bathhouse and say to her companions, "Pass before me, for I am laden with kings." Isaac and Jacob were sitting in judgment, and Judah said, "Bring her out, and let her be burned" (Genesis 38:24), for in capital cases one begins [taking the opinions] from the side [the junior members first].
Tamar and Zimri and the Two Kinds of Harlotry
Yalkut Shimoni on Torah 145:7
וְגַם הִנֵּה הָרָה לִזְנוּנִים. אָמַר עוּלָא, תָּמָר זָנְתָה, זִמְרִי זָנָה, תָּמָר זָנְתָה יָצְאוּ מִמֶּנָּהּ מְלָכִים וּנְבִיאִים זִמְרִי זָנָה נָפְלוּ כַּמָּה רְבָבוֹת מִיִּשְׂרָאֵל. וְגַם הִנֵּה הָרָה לִזְנוּנִים. שֶׁהָיְתָה נִכְנֶסֶת לַמֶּרְחָץ וְאוֹמֶרֶת לְחַבְרוֹתֶיהָ, עִבְרוּ מִלְּפָנַי שֶׁאֲנִי טְעוּנָה מְלָכִים. וְהָיָה יוֹשֵׁב בַּדִּין יִצְחָק וְיַעֲקֹב, וִיהוּדָה אָמַר הוֹצִיאוּהָ וְתִשָּׂרֵף, לְפִי שֶׁבְּדִינֵי נְפָשׁוֹת מַתְחִילִין מִן הַצַּד.