diff options
author | Araq <rumpf_a@web.de> | 2013-05-27 23:18:15 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-05-27 23:18:15 +0200 |
commit | e3f93241c3824e49b69c647bbd44726a79e8f8f8 (patch) | |
tree | 8a56266270506f483ba93c71ac34d491b6f2e4dd | |
parent | 9c45e33d8c8b1a5f5fca69a467fda87b9b547057 (diff) | |
download | Nim-e3f93241c3824e49b69c647bbd44726a79e8f8f8.tar.gz |
Revert "fix tforwardgeneric"
This reverts commit d82a032566de1612ff1ed2d82cc7ec2bd58267d7.
-rw-r--r-- | compiler/ast.nim | 4 | ||||
-rw-r--r-- | compiler/lambdalifting.nim | 3 | ||||
-rw-r--r-- | compiler/seminst.nim | 2 | ||||
-rw-r--r-- | tests/compile/tforwardgeneric.nim | 5 |
4 files changed, 6 insertions, 8 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 5f3ce2613..174c3f94b 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1285,9 +1285,9 @@ 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 = s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty else: nil - + proc isRoutine*(s: PSym): bool {.inline.} = result = s.kind in {skProc, skTemplate, skMacro, skIterator, skMethod, skConverter} diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 163ea4136..8d4946ab5 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -288,9 +288,6 @@ proc interestingVar(s: PSym): bool {.inline.} = proc semCaptureSym*(s, owner: PSym) = if interestingVar(s) and owner.id != s.owner.id and s.kind != skResult: if owner.typ != nil and not isGenericRoutine(owner): - # XXX: is this really safe? - # if we capture a var from another generic routine, - # it won't be consider captured. owner.typ.callConv = ccClosure #echo "semCaptureSym ", owner.name.s, owner.id, " ", s.name.s, s.id # since the analysis is not entirely correct, we don't set 'tfCapturesEnv' diff --git a/compiler/seminst.nim b/compiler/seminst.nim index 431635b9c..35ed00965 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -125,6 +125,8 @@ proc fixupInstantiatedSymbols(c: PContext, s: PSym) = openScope(c) var n = oldPrc.ast n.sons[bodyPos] = copyTree(s.getBody) + if n.sons[paramsPos].kind != nkEmpty: + addParams(c, oldPrc.typ.n, oldPrc.kind) instantiateBody(c, n, oldPrc) closeScope(c) popInfoContext() diff --git a/tests/compile/tforwardgeneric.nim b/tests/compile/tforwardgeneric.nim index c5943b966..ef263d733 100644 --- a/tests/compile/tforwardgeneric.nim +++ b/tests/compile/tforwardgeneric.nim @@ -1,5 +1,5 @@ discard """ - output: "1.1000000000000001e+00 11" + output: "1.0000000000000000e+00 10" ccodecheck: "!@'ClEnv'" """ @@ -8,6 +8,5 @@ proc p[T](a, b: T): T echo p(0.9, 0.1), " ", p(9, 1) proc p[T](a, b: T): T = - let c = b - result = a + b + c + result = a + b |