diff options
Diffstat (limited to 'compiler/semtempl.nim')
-rw-r--r-- | compiler/semtempl.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 3b2f2dd9e..6c01be7ea 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -635,6 +635,7 @@ proc semTemplateDef(c: PContext, n: PNode): PNode = setGenericParamsMisc(c, n) # process parameters: var allUntyped = true + var requiresParams = false if n[paramsPos].kind != nkEmpty: semParamList(c, n[paramsPos], n[genericParamsPos], s) # a template's parameters are not gensym'ed even if that was originally the @@ -646,6 +647,8 @@ proc semTemplateDef(c: PContext, n: PNode): PNode = param.flags.incl sfTemplateParam param.flags.excl sfGenSym if param.typ.kind != tyUntyped: allUntyped = false + # no default value, parameters required in call + if param.ast == nil: requiresParams = true else: s.typ = newTypeS(tyProc, c) # XXX why do we need tyTyped as a return type again? @@ -657,6 +660,11 @@ proc semTemplateDef(c: PContext, n: PNode): PNode = n[genericParamsPos] = n[miscPos][1] n[miscPos] = c.graph.emptyNode if allUntyped: incl(s.flags, sfAllUntyped) + if requiresParams or + n[bodyPos].kind == nkEmpty or + n[genericParamsPos].kind != nkEmpty: + # template cannot be called with alias syntax + incl(s.flags, sfNoalias) if n[patternPos].kind != nkEmpty: n[patternPos] = semPattern(c, n[patternPos], s) |