summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/types.nim5
-rw-r--r--tests/metatype/tautotypetrait.nim14
2 files changed, 18 insertions, 1 deletions
diff --git a/compiler/types.nim b/compiler/types.nim
index ff3572517..70b4b5aa2 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -1333,7 +1333,10 @@ proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt =
     if typ.callConv == ccClosure: result = 2 * ptrSize
     else: result = ptrSize
     a = ptrSize
-  of tyNil, tyCString, tyString, tySequence, tyPtr, tyRef, tyVar, tyLent, tyOpenArray:
+  of tyString, tyNil:
+    result = ptrSize
+    a = result
+  of tyCString, tySequence, tyPtr, tyRef, tyVar, tyLent, tyOpenArray:
     let base = typ.lastSon
     if base == typ or (base.kind == tyTuple and base.size==szIllegalRecursion):
       result = szIllegalRecursion
diff --git a/tests/metatype/tautotypetrait.nim b/tests/metatype/tautotypetrait.nim
new file mode 100644
index 000000000..4040197c3
--- /dev/null
+++ b/tests/metatype/tautotypetrait.nim
@@ -0,0 +1,14 @@
+discard """
+  output: "(Field0: "string", Field1: "string")"
+"""
+
+# 7528
+import macros
+import typetraits
+
+macro bar*(n: untyped): typed =
+  result = newNimNode(nnkStmtList, n)
+  result.add(newCall("write", newIdentNode("stdout"), n))
+
+proc foo0[T](): auto = return (T.name, T.name)
+bar foo0[string]()