summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2018-02-10 15:44:41 +0000
committerAndreas Rumpf <rumpf_a@web.de>2018-02-10 16:44:41 +0100
commit51d81c4e23c7f5513a1b2028f02509c860021278 (patch)
treeec5f0b8f8569a4447a3feb64df1022460e7918a7
parent29226ce5b2d6267faf45644d3e058c782610f2df (diff)
downloadNim-51d81c4e23c7f5513a1b2028f02509c860021278.tar.gz
Fixes #6853 (#7188)
* Fixes #6853
* Add a test for a const empty array
-rw-r--r--compiler/sigmatch.nim7
-rw-r--r--tests/array/tarray.nim8
2 files changed, 14 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 090f30f16..aba36d24d 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1145,7 +1145,12 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
           fRange = prev
       let ff = f.sons[1].skipTypes({tyTypeDesc})
       let aa = a.sons[1].skipTypes({tyTypeDesc})
-      result = typeRel(c, ff, aa)
+      
+      if f.sons[0].kind != tyGenericParam and aa.kind == tyEmpty:
+        result = isGeneric  
+      else:
+        result = typeRel(c, ff, aa)
+     
       if result < isGeneric:
         if nimEnableCovariance and
            trNoCovariance notin flags and
diff --git a/tests/array/tarray.nim b/tests/array/tarray.nim
index 9cfb758e2..95d1bb7cc 100644
--- a/tests/array/tarray.nim
+++ b/tests/array/tarray.nim
@@ -38,3 +38,11 @@ var found: array[0..filesToCreate.high, bool]
 
 echo found.len
 
+# make sure empty arrays are assignable (bug #6853)
+const arr1: array[0, int] = []
+const arr2 = []
+let arr3: array[0, string] = []
+
+doAssert(arr1.len == 0)
+doAssert(arr2.len == 0)
+doAssert(arr3.len == 0)