diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-03-09 15:09:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-09 08:09:08 +0100 |
commit | 72e262666bdf2bb3c239183dd32b48bb05d113aa (patch) | |
tree | 263bea109063b9700efcdb523ea8db5e09a950f5 | |
parent | 8e9fc5e63968177c75d93af08d32717bf6c97693 (diff) | |
download | Nim-72e262666bdf2bb3c239183dd32b48bb05d113aa.tar.gz |
fixes quoted variables with typedesc types (#21493)
-rw-r--r-- | compiler/semexprs.nim | 2 | ||||
-rw-r--r-- | tests/stdlib/tmacros.nim | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 976d7c757..cfa34fcdc 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -2206,7 +2206,7 @@ proc semQuoteAst(c: PContext, n: PNode): PNode = dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[0], getSysSym(c.graph, n.info, "typed").newSymNode, c.graph.emptyNode) for i in 1..<ids.len: let typ = semExprWithType(c, quotes[i+1], {}).typ - if tfTriggersCompileTime notin typ.flags: + if tfTriggersCompileTime notin typ.flags and typ.kind != tyTypeDesc: dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[i], newNodeIT(nkType, n.info, typ), c.graph.emptyNode) else: dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[i], getSysSym(c.graph, n.info, "typed").newSymNode, c.graph.emptyNode) diff --git a/tests/stdlib/tmacros.nim b/tests/stdlib/tmacros.nim index a03bcca2d..9e3ebee83 100644 --- a/tests/stdlib/tmacros.nim +++ b/tests/stdlib/tmacros.nim @@ -311,3 +311,11 @@ block: # bug #9607 doAssert echoL() == "bar" doAssert echoM() == "bar" + +block: + macro hello[T](x: T): untyped = + result = quote do: + let m: `T` = `x` + discard m + + hello(12) |