From 57138f8cf94f0a55b615be9802ce76f6a6858f22 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 30 Jul 2021 09:59:52 -0700 Subject: Do not crash in ExtractFunction if an export already exists (#4040) We just cleared the list of exports, but the exportMap was still populated, so the data was in an inconsistent state. This fixes the case of running --extract-function multiple times on a file (which is usually not useful, unless one of the passes you are debugging adds new functions to the file - which some do). --- src/passes/ExtractFunction.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/passes/ExtractFunction.cpp b/src/passes/ExtractFunction.cpp index a219000c8..0c0c1477e 100644 --- a/src/passes/ExtractFunction.cpp +++ b/src/passes/ExtractFunction.cpp @@ -46,6 +46,7 @@ static void extract(PassRunner* runner, Module* module, Name name) { // Leave just one export, for the thing we want. module->exports.clear(); + module->updateMaps(); module->addExport(Builder::makeExport(name, name, ExternalKind::Function)); // Remove unneeded things. -- cgit v1.2.3