diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-12-29 17:21:00 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-12-29 17:21:00 +0200 |
commit | afddae5aaf08a3a3357ec33d0bc82bdba0f5dc08 (patch) | |
tree | b6bd783f813797dcb5be4abaaade5ad599bb1c5c /compiler/semstmts.nim | |
parent | 437cfa73abd8fdf878cc2af2c44acbc4b6ec3a56 (diff) | |
parent | 72291875bf895e8e0d22ab3f375752417b07ed25 (diff) | |
download | Nim-afddae5aaf08a3a3357ec33d0bc82bdba0f5dc08.tar.gz |
Merge branch 'upstream' into devel
Conflicts: compiler/ccgutils.nim compiler/msgs.nim compiler/sem.nim compiler/semexprs.nim compiler/seminst.nim compiler/semmagic.nim compiler/semstmts.nim compiler/semtypes.nim compiler/semtypinst.nim compiler/sigmatch.nim compiler/types.nim compiler/vmgen.nim lib/core/macros.nim lib/system.nim tests/reject/tenummix.nim web/news.txt
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 1766c4446..3cc338d8a 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1037,12 +1037,16 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, pushOwner(s) s.options = gOptions if sfDestructor in s.flags: doDestructorStuff(c, s, n) - if n.sons[bodyPos].kind != nkEmpty: + if n.sons[bodyPos].kind != nkEmpty: # for DLL generation it is annoying to check for sfImportc! - if sfBorrow in s.flags: + if sfBorrow in s.flags: localError(n.sons[bodyPos].info, errImplOfXNotAllowed, s.name.s) - if n.sons[genericParamsPos].kind == nkEmpty: - paramsTypeCheck(c, s.typ) + let usePseudoGenerics = kind in {skMacro, skTemplate} + # Macros and Templates can have generic parameters, but they are + # only used for overload resolution (there is no instantiation of + # the symbol, so we must process the body now) + if n.sons[genericParamsPos].kind == nkEmpty or usePseudoGenerics: + if not usePseudoGenerics: paramsTypeCheck(c, s.typ) pushProcCon(c, s) maybeAddResult(c, s, n) if sfImportc notin s.flags: @@ -1052,13 +1056,13 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, # context as it may even be evaluated in 'system.compiles': n.sons[bodyPos] = transformBody(c.module, semBody, s) popProcCon(c) - else: + else: if s.typ.sons[0] != nil and kind != skIterator: addDecl(c, newSym(skUnknown, getIdent"result", nil, n.info)) var toBind = initIntSet() n.sons[bodyPos] = semGenericStmtScope(c, n.sons[bodyPos], {}, toBind) fixupInstantiatedSymbols(c, s) - if sfImportc in s.flags: + if sfImportc in s.flags: # so we just ignore the body after semantic checking for importc: n.sons[bodyPos] = ast.emptyNode else: |