diff options
-rw-r--r-- | compiler/semtypes.nim | 3 | ||||
-rw-r--r-- | tests/generics/taliashijack.nim | 8 | ||||
-rw-r--r-- | tests/vm/tvmmisc.nim | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 1219d6ed8..a5cd5b5b0 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 000000000..fdebadded --- /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 d28f76574..3c4b47c48 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: |