proc arguments are in scope when the result type definition is being processed

This is intended for type deduction depending on the arguments
proc foo(x: type): type(expr(x))
This commit is contained in:
Zahary Karadjov 2011-12-09 15:56:48 +02:00
commit de4b894541
5 changed files with 16 additions and 5 deletions

View file

@ -185,7 +185,8 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
# use ``stmt`` as implicit result type
s.typ.sons[0] = newTypeS(tyStmt, c)
s.typ.n.sons[0] = newNodeIT(nkType, n.info, s.typ.sons[0])
addParams(c, s.typ.n) # resolve parameters:
# XXX: obsoleted - happens in semParamList #
# addParams(c, s.typ.n) # resolve parameters:
var toBind = initIntSet()
n.sons[bodyPos] = resolveTemplateParams(c, n.sons[bodyPos], false, toBind)
if s.typ.sons[0].kind notin {tyStmt, tyTypeDesc}: