Fix type comparison in semConv (#8907)

Fixes #8905
This commit is contained in:
LemonBoy
2018-09-07 21:06:30 +02:00
committed by Andreas Rumpf
parent 90025e242d
commit e69d8ec416
2 changed files with 9 additions and 1 deletions

View File

@@ -113,6 +113,7 @@ proc checkConvertible(c: PContext, castDest, src: PType): TConvStatus =
if castDest.kind notin IntegralTypes+{tyRange}:
result = convNotNeedeed
return
# Save for later
var d = skipTypes(castDest, abstractVar)
var s = src
if s.kind in tyUserTypeClasses and s.isResolvedUserTypeClass:
@@ -135,7 +136,7 @@ proc checkConvertible(c: PContext, castDest, src: PType): TConvStatus =
# we use d, s here to speed up that operation a bit:
case cmpTypes(c, d, s)
of isNone, isGeneric:
if not compareTypes(castDest, src, dcEqIgnoreDistinct):
if not compareTypes(castDest.skipTypes(abstractVar), src, dcEqIgnoreDistinct):
result = convNotLegal
else:
discard

7
tests/typerel/t8905.nim Normal file
View File

@@ -0,0 +1,7 @@
type
Foo[T] = distinct seq[T]
Bar[T] = object
proc newFoo[T](): Foo[T] = Foo[T](newSeq[T]())
var x = newFoo[Bar[int]]()