This commit is contained in:
Andreas Rumpf 2019-08-29 00:35:05 +02:00 • committed by GitHub
commit 5f7a6aff06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View file

@ -403,7 +403,13 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode,
if s.typ.sons[0] == nil:
result = semStmt(c, result, flags)
else:
case s.typ.sons[0].kind
var retType = s.typ.sons[0]
if retType.kind == tyTypeDesc and tfUnresolved in retType.flags and
retType.len == 1:
# bug #11941: template fails(T: type X, v: auto): T
# does not mean we expect a tyTypeDesc.
retType = retType[0]
case retType.kind
of tyUntyped:
# Not expecting a type here allows templates like in ``tmodulealias.in``.
result = semExpr(c, result, flags)
@ -421,7 +427,6 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode,
result.typ = makeTypeDesc(c, typ)
#result = symNodeFromType(c, typ, n.info)
else:
var retType = s.typ.sons[0]
if s.ast[genericParamsPos] != nil and retType.isMetaType:
# The return type may depend on the Macro arguments
# e.g. template foo(T: typedesc): seq[T]