summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-08-29 11:33:41 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-08-29 11:33:41 +0200
commit154db46db817fff315b1a0ef2da36511e382cfad (patch)
treebb729c758dd394a3ec246977809e2b1cc4258fc5
parent7e3ebc1bccb689176cfadd485fe8777bc343a5e6 (diff)
downloadNim-154db46db817fff315b1a0ef2da36511e382cfad.tar.gz
fixes a regression that caused --import in a config file to break things
-rw-r--r--compiler/importer.nim5
-rw-r--r--tests/import_in_config/nim.cfg2
-rw-r--r--tests/import_in_config/other.nim0
-rw-r--r--tests/import_in_config/tmain.nim0
4 files changed, 6 insertions, 1 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim
index 7e7130b85..87415733b 100644
--- a/compiler/importer.nim
+++ b/compiler/importer.nim
@@ -163,7 +163,10 @@ proc myImportModule(c: PContext, n: PNode): PSym =
   var f = checkModuleName(n)
   if f != InvalidFileIDX:
     result = importModuleAs(n, gImportModule(c.module, f))
-    if result.info.fileIndex == c.module.info.fileIndex:
+    # we cannot perform this check reliably because of
+    # test: modules/import_in_config)
+    if result.info.fileIndex == c.module.info.fileIndex and
+        result.info.fileIndex == n.info.fileIndex:
       localError(n.info, errGenerated, "A module cannot import itself")
     if sfDeprecated in result.flags:
       message(n.info, warnDeprecated, result.name.s)
diff --git a/tests/import_in_config/nim.cfg b/tests/import_in_config/nim.cfg
new file mode 100644
index 000000000..af112d112
--- /dev/null
+++ b/tests/import_in_config/nim.cfg
@@ -0,0 +1,2 @@
+import = "other"
+path = "$projectDir"
diff --git a/tests/import_in_config/other.nim b/tests/import_in_config/other.nim
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/import_in_config/other.nim
diff --git a/tests/import_in_config/tmain.nim b/tests/import_in_config/tmain.nim
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/import_in_config/tmain.nim