Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1425,13 +1425,15 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
if a.kind == tyArray:
var fRange = f.indexType
var aRange = a.indexType
var indexRel = isEqual
if fRange.kind in {tyGenericParam, tyAnything}:
var prev = lookup(c.bindings, fRange)
if prev == nil:
if typeRel(c, fRange, aRange) == isNone:
indexRel = typeRel(c, fRange, aRange)
if indexRel == isNone:
return isNone
put(c, fRange, a.indexType)
fRange = a
fRange = aRange
else:
fRange = prev
let ff = f[1].skipTypes({tyTypeDesc})
Expand All @@ -1442,6 +1444,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
result = isGeneric
else:
result = typeRel(c, ff, aa, flags)
if indexRel == isGeneric and result > isGeneric:
result = isGeneric
if result < isGeneric:
if nimEnableCovariance and
trNoCovariance notin flags and
Expand Down
6 changes: 6 additions & 0 deletions tests/generics/tgenerics_various.nim
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,9 @@ block: # issue #9381

var x: GenericObj[int]
static: doAssert evalCount == 1

block: # bug #22861
proc fromHex[N](A: type array[N, int]) = discard
proc fromHex (T: typedesc[array[1, int]]) = discard
fromHex(array[1, int])

Loading