diff options
-rw-r--r-- | compiler/sigmatch.nim | 2 | ||||
-rw-r--r-- | tests/generics/tobjecttyperel3.nim | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index ff7b0ae72..4661abda0 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1268,7 +1268,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = # crossing path with metatypes/aliases, so we need to separate them # by checking sym.id let genericSubtype = isGenericSubType(c, x, f, depth, f) - if not (genericSubtype and aobj.sym.id != fobj.sym.id): + if not (genericSubtype and aobj.sym.id != fobj.sym.id) and aOrig.kind != tyGenericBody: depth = -1 if depth >= 0: diff --git a/tests/generics/tobjecttyperel3.nim b/tests/generics/tobjecttyperel3.nim new file mode 100644 index 000000000..3d8079e28 --- /dev/null +++ b/tests/generics/tobjecttyperel3.nim @@ -0,0 +1,12 @@ +discard """ + output: '''OK''' +""" +#bug #5632 +type + Option*[T] = object + +proc point*[A](v: A, t: typedesc[Option[A]]): Option[A] = + discard + +discard point(1, Option) +echo "OK" \ No newline at end of file |