From eab46c5b7e2d2fe34b4d2c6c53d690940e9d4b99 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 17 Dec 2017 13:42:56 +0100 Subject: [PATCH] runnableExamples feature: allow import statements and move them to the top level --- compiler/semexprs.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 532566a184..28a97068bf 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1775,6 +1775,13 @@ proc setMs(n: PNode, s: PSym): PNode = n.sons[0] = newSymNode(s) n.sons[0].info = n.info +proc extractImports(n: PNode; result: PNode) = + if n.kind in {nkImportStmt, nkImportExceptStmt, nkFromStmt}: + result.add copyTree(n) + n.kind = nkEmpty + return + for i in 0..