fix #18986; Import/except doesn't work on devel [backport: 1.6] (#19687)

* fix #18986; Import/except doesn't work on devel [backport: 1.6]

* add testcase
This commit is contained in:
flywind
2022-04-06 22:17:09 +08:00
committed by GitHub
parent 83dabb69ae
commit 5a995ffc53
3 changed files with 14 additions and 1 deletions

View File

@@ -202,7 +202,7 @@ template addUnnamedIt(c: PContext, fromMod: PSym; filter: untyped) {.dirty.} =
proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: IntSet) =
c.addImport ImportedModule(m: fromMod, mode: importExcept, exceptSet: exceptSet)
addUnnamedIt(c, fromMod, it.sym.id notin exceptSet)
addUnnamedIt(c, fromMod, it.sym.name.id notin exceptSet)
proc importAllSymbols*(c: PContext, fromMod: PSym) =
c.addImport ImportedModule(m: fromMod, mode: importAll)

View File

@@ -0,0 +1,3 @@
import std/macros
converter Lit*(x: uint): NimNode = newLit(x)

View File

@@ -0,0 +1,10 @@
discard """
output: "Found a 0"
"""
import m18986 except Lit
import std/macros
# bug #18986
var x = 0.uint
echo "Found a ", x