fix is with generic types; fix genericHead(Foo[T]) (#13303)

* fix #9855, fix #9855, fix genericHead
* render TTypeKind via toHumanStr
This commit is contained in:
Timothee Cour 2020-02-09 04:48:55 -08:00 • committed by GitHub
commit 7939319379
7 changed files with 94 additions and 20 deletions

View file

@ -396,12 +396,21 @@ proc isOpImpl(c: PContext, n: PNode, flags: TExprFlags): PNode =
else:
res = false
else:
maybeLiftType(t2, c, n.info)
if t1.skipTypes({tyGenericInst, tyAlias, tySink, tyDistinct}).kind != tyGenericBody:
maybeLiftType(t2, c, n.info)
else:
#[
for this case:
type Foo = object[T]
Foo is Foo
]#
discard
var m = newCandidate(c, t2)
if efExplain in flags:
m.diagnostics = @[]
m.diagnosticsEnabled = true
res = typeRel(m, t2, t1) >= isSubtype # isNone
# `res = sameType(t1, t2)` would be wrong, eg for `int is (int|float)`
result = newIntNode(nkIntLit, ord(res))
result.typ = n.typ