From 911e6e710f28f454cf8bc1bb493c1a28c4694b76 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 26 May 2013 21:06:39 +0300 Subject: [PATCH] more test made green the lambda lifting was trying too hard to ignore generic prods isGenericRoutine was producing false-negatives and only this allowed for some of the warning and error messages to be triggered. some files with mixed line endings were fixed --- compiler/ast.nim | 3 +- compiler/lambdalifting.nim | 2 +- compiler/seminst.nim | 37 +++++++++------- compiler/semtypes.nim | 2 +- tests/compile/tobjects.nim | 86 +++++++++++++++++++------------------- tests/compile/toverprc.nim | 55 ++++++++++++------------ 6 files changed, 96 insertions(+), 89 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index 5f3ce2613..00e4b3bda 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1285,7 +1285,8 @@ proc getStrOrChar*(a: PNode): string = proc isGenericRoutine*(s: PSym): bool = case s.kind of skProc, skTemplate, skMacro, skIterator, skMethod, skConverter: - result = sfFromGeneric in s.flags + result = sfFromGeneric in s.flags or + (s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty) else: nil proc isRoutine*(s: PSym): bool {.inline.} = diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 163ea4136..9a40b350e 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -220,7 +220,7 @@ proc getHiddenParam(routine: PSym): PSym = proc isInnerProc(s, outerProc: PSym): bool {.inline.} = result = s.kind in {skProc, skMethod, skConverter} and - s.owner == outerProc and not isGenericRoutine(s) + s.owner == outerProc #s.typ.callConv == ccClosure proc addClosureParam(i: PInnerContext, e: PEnv) = diff --git a/compiler/seminst.nim b/compiler/seminst.nim index ed842d98e..15be33261 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -91,17 +91,8 @@ proc instantiateBody(c: PContext, n: PNode, result: PSym) = addDecl(c, result) pushProcCon(c, result) # add params to scope - let origFormalParams = result.typ.n - result.typ.n = newNodeI(nkFormalParams, - origFormalParams.info, - origFormalParams.len) - result.typ.n.sons[0] = copyNode(origFormalParams.sons[0]) - for i in 1 ..