summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--changelog.md2
-rw-r--r--compiler/importer.nim2
-rw-r--r--compiler/semexprs.nim4
-rw-r--r--tests/modules/mrange.nim2
-rw-r--r--tests/modules/tambig_range.nim9
5 files changed, 16 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md
index ea3176705..bf83a79fa 100644
--- a/changelog.md
+++ b/changelog.md
@@ -132,3 +132,5 @@ This now needs to be written as:
   the new ``rand`` procs. The module now exports the state of the random
   number generator as type ``Rand`` so multiple threads can easily use their
   own random number generators that do not require locking.
+- The compiler is now more consistent in its treatment of ambiguous symbols:
+  Types that shadow procs and vice versa are marked as ambiguous (bug #6693).
diff --git a/compiler/importer.nim b/compiler/importer.nim
index 89ee00b9d..46d675b27 100644
--- a/compiler/importer.nim
+++ b/compiler/importer.nim
@@ -27,7 +27,7 @@ proc rawImportSymbol(c: PContext, s: PSym) =
   # check if we have already a symbol of the same name:
   var check = strTableGet(c.importTable.symbols, s.name)
   if check != nil and check.id != s.id:
-    if s.kind notin OverloadableSyms:
+    if s.kind notin OverloadableSyms or check.kind notin OverloadableSyms:
       # s and check need to be qualified:
       incl(c.ambiguousSymbols, s.id)
       incl(c.ambiguousSymbols, check.id)
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 65b111d8f..af6322b2b 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -2217,10 +2217,10 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
         # XXX think about this more (``set`` procs)
         if n.len == 2:
           result = semConv(c, n)
-        elif n.len == 1:
-          result = semObjConstr(c, n, flags)
         elif contains(c.ambiguousSymbols, s.id):
           errorUseQualifier(c, n.info, s)
+        elif n.len == 1:
+          result = semObjConstr(c, n, flags)
         elif s.magic == mNone: result = semDirectOp(c, n, flags)
         else: result = semMagic(c, n, s, flags)
       of skProc, skFunc, skMethod, skConverter, skIterator:
diff --git a/tests/modules/mrange.nim b/tests/modules/mrange.nim
new file mode 100644
index 000000000..9b78bf24b
--- /dev/null
+++ b/tests/modules/mrange.nim
@@ -0,0 +1,2 @@
+
+proc range*() = echo "yo"
\ No newline at end of file
diff --git a/tests/modules/tambig_range.nim b/tests/modules/tambig_range.nim
new file mode 100644
index 000000000..48e0e9f52
--- /dev/null
+++ b/tests/modules/tambig_range.nim
@@ -0,0 +1,9 @@
+discard """
+  errormsg: "ambiguous identifier: 'range' --use system.range or mrange.range"
+  line: 9
+"""
+
+# bug #6726
+import mrange
+
+range()