* Fixes #6853
* Add a test for a const empty array
This commit is contained in:
cooldome
2018-02-10 15:44:41 +00:00
committed by Andreas Rumpf
parent 29226ce5b2
commit 51d81c4e23
2 changed files with 14 additions and 1 deletions

View File

@@ -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

View File

@@ -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)