diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-01-08 18:02:38 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-01-08 18:02:38 +0100 |
commit | ceb8ba49576ed0f27cf6ec031369c42ddf68757d (patch) | |
tree | 9588060ff4e7b106f71c1328710e51391c4f1260 /compiler | |
parent | cdc104f69a8fa61c38e950e2ffe279c900857081 (diff) | |
download | Nim-ceb8ba49576ed0f27cf6ec031369c42ddf68757d.tar.gz |
fixes #7018
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semexprs.nim | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 51e75e91f..f4f691889 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1865,17 +1865,16 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode = result = magicsAfterOverloadResolution(c, result, flags) of mRunnableExamples: if gCmd == cmdDoc and n.len >= 2 and n.lastSon.kind == nkStmtList: - if n.sons[0].kind == nkIdent: - if sfMainModule in c.module.flags: - let inp = toFullPath(c.module.info) - if c.runnableExamples == nil: - c.runnableExamples = newTree(nkStmtList, - newTree(nkImportStmt, newStrNode(nkStrLit, expandFilename(inp)))) - let imports = newTree(nkStmtList) - extractImports(n.lastSon, imports) - for imp in imports: c.runnableExamples.add imp - c.runnableExamples.add newTree(nkBlockStmt, emptyNode, copyTree n.lastSon) - result = setMs(n, s) + if sfMainModule in c.module.flags: + let inp = toFullPath(c.module.info) + if c.runnableExamples == nil: + c.runnableExamples = newTree(nkStmtList, + newTree(nkImportStmt, newStrNode(nkStrLit, expandFilename(inp)))) + let imports = newTree(nkStmtList) + extractImports(n.lastSon, imports) + for imp in imports: c.runnableExamples.add imp + c.runnableExamples.add newTree(nkBlockStmt, emptyNode, copyTree n.lastSon) + result = setMs(n, s) else: result = emptyNode else: |