diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 1219d6ed83..a5cd5b5b02 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1646,7 +1646,8 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = recomputeFieldPositions(tx, tx.n, position) proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType = - if typeExpr.kind in {tyObject, tyEnum, tyDistinct, tyForward, tyGenericBody} and prev != nil: + if prev != nil and (prev.kind == tyGenericBody or + typeExpr.kind in {tyObject, tyEnum, tyDistinct, tyForward, tyGenericBody}): result = newTypeS(tyAlias, c) result.rawAddSon typeExpr result.sym = prev.sym diff --git a/tests/generics/taliashijack.nim b/tests/generics/taliashijack.nim new file mode 100644 index 0000000000..fdebadded2 --- /dev/null +++ b/tests/generics/taliashijack.nim @@ -0,0 +1,8 @@ +# issue #23977 + +type Foo[T] = int + +proc foo(T: typedesc) = + var a: T + +foo(int) diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index d28f765740..3c4b47c48d 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -566,7 +566,7 @@ block: block: static: let x = int 1 - doAssert $(x.type) == "Foo" # Foo + doAssert $(x.type) == "int" # Foo block: static: