summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2022-04-06 22:17:09 +0800
committerGitHub <noreply@github.com>2022-04-06 16:17:09 +0200
commit5a995ffc53ac7c1a51ab62440a58af2f4e43963b (patch)
treee617742b477a3c526532634877f384a90226935e
parent83dabb69ae0f6c0bb269594a5b73af964b809bc7 (diff)
downloadNim-5a995ffc53ac7c1a51ab62440a58af2f4e43963b.tar.gz
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
-rw-r--r--compiler/importer.nim2
-rw-r--r--tests/converter/m18986.nim3
-rw-r--r--tests/converter/t18986.nim10
3 files changed, 14 insertions, 1 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim
index 719b75f0f..c4e37c269 100644
--- a/compiler/importer.nim
+++ b/compiler/importer.nim
@@ -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)
diff --git a/tests/converter/m18986.nim b/tests/converter/m18986.nim
new file mode 100644
index 000000000..0ebf343ae
--- /dev/null
+++ b/tests/converter/m18986.nim
@@ -0,0 +1,3 @@
+import std/macros
+
+converter Lit*(x: uint): NimNode = newLit(x)
diff --git a/tests/converter/t18986.nim b/tests/converter/t18986.nim
new file mode 100644
index 000000000..ef300fa49
--- /dev/null
+++ b/tests/converter/t18986.nim
@@ -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