diff options
-rw-r--r-- | compiler/semtypinst.nim | 3 | ||||
-rw-r--r-- | tests/generics/t19848.nim | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index e87a4939a..276424512 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -573,6 +573,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType = result.kind = tyUserTypeClassInst of tyGenericBody: + if cl.allowMetaTypes: return localError( cl.c.config, cl.info, @@ -645,7 +646,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType = for i, resulti in result.ikids: if resulti != nil: - if resulti.kind == tyGenericBody: + if resulti.kind == tyGenericBody and not cl.allowMetaTypes: localError(cl.c.config, if t.sym != nil: t.sym.info else: cl.info, "cannot instantiate '" & typeToString(result[i], preferDesc) & diff --git a/tests/generics/t19848.nim b/tests/generics/t19848.nim new file mode 100644 index 000000000..f80f0e298 --- /dev/null +++ b/tests/generics/t19848.nim @@ -0,0 +1,16 @@ +discard """ + output: ''' +todo +''' +""" + +type + Maybe[T] = object + List[T] = object + +proc dump[M: Maybe](a: List[M]) = + echo "todo" + +var a: List[Maybe[int]] + +dump(a) |