summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-04-06 22:42:25 +0200
committerAraq <rumpf_a@web.de>2018-04-06 22:42:25 +0200
commit8b7c2bd06783c916c9f3725ee571bf2463140a73 (patch)
treefe0e8b733c4f7f538d63fef23c219975d9d9fa85
parent2d686743386076a3edbfd1db4723cf9f3064f08c (diff)
downloadNim-8b7c2bd06783c916c9f3725ee571bf2463140a73.tar.gz
fixes #7528
-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]()