summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2019-05-15 19:16:32 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-05-15 19:16:32 +0200
commit4e0e706cfe90840043dfff965e0f2f544e8f3698 (patch)
tree3a59146a3d0f914bfd3879c841ea2e39d3a97c53
parent791abfbc165c11c725358a0279301af9a3094569 (diff)
downloadNim-4e0e706cfe90840043dfff965e0f2f544e8f3698.tar.gz
Correct global destructor injections for js backend (#11240)
-rw-r--r--compiler/jsgen.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 795f1012f..5387631dc 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -2620,6 +2620,9 @@ proc getClassName(t: PType): Rope =
 proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
   result = myProcess(b, n)
   var m = BModule(b)
+  if sfMainModule in m.module.flags:
+    for destructorCall in graph.globalDestructors:
+      n.add destructorCall
   if passes.skipCodegen(m.config, n): return n
   if sfMainModule in m.module.flags:
     let code = wholeCode(graph, m)