summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/docgen2.nim2
-rw-r--r--compiler/semmagic.nim1
-rw-r--r--tests/metatype/ttypetraits.nim5
3 files changed, 7 insertions, 1 deletions
diff --git a/compiler/docgen2.nim b/compiler/docgen2.nim
index b5ef7e32d..438417ca0 100644
--- a/compiler/docgen2.nim
+++ b/compiler/docgen2.nim
@@ -11,7 +11,7 @@
 # semantic checking.
 
 import
-  options, ast, msgs, idents, passes, docgen, lineinfos, pathutils
+  options, ast, msgs, passes, docgen, lineinfos, pathutils
 
 from modulegraphs import ModuleGraph, PPassContext
 
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 0cd5a5332..41a920371 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -176,6 +176,7 @@ proc evalTypeTrait(c: PContext; traitCall: PNode, operand: PType, context: PSym)
                      hasDestructor(t)
     result = newIntNodeT(toInt128(ord(not complexObj)), traitCall, c.graph)
   of "isNamedTuple":
+    var operand = operand.skipTypes({tyGenericInst})
     let cond = operand.kind == tyTuple and operand.n != nil
     result = newIntNodeT(toInt128(ord(cond)), traitCall, c.graph)
   of "distinctBase":
diff --git a/tests/metatype/ttypetraits.nim b/tests/metatype/ttypetraits.nim
index dfd22b418..2b474ba7f 100644
--- a/tests/metatype/ttypetraits.nim
+++ b/tests/metatype/ttypetraits.nim
@@ -6,6 +6,8 @@ block: # isNamedTuple
   type Foo2 = (Field0:1,).type
   type Foo3 = ().type
   type Foo4 = object
+  type Foo5[T] = tuple[x:int, y: T]
+  type Foo6[T] = (T,)
 
   doAssert (a:1,).type.isNamedTuple
   doAssert Foo1.isNamedTuple
@@ -14,6 +16,9 @@ block: # isNamedTuple
   doAssert not Foo3.isNamedTuple
   doAssert not Foo4.isNamedTuple
   doAssert not (1,).type.isNamedTuple
+  doAssert isNamedTuple(Foo5[int8])
+  doAssert not isNamedTuple(Foo5)
+  doAssert not isNamedTuple(Foo6[int8])
 
 proc typeToString*(t: typedesc, prefer = "preferTypeName"): string {.magic: "TypeTrait".}
   ## Returns the name of the given type, with more flexibility than `name`,