This commit is contained in:
Araq
2015-08-09 20:18:49 +02:00
parent f8bababa2a
commit 35f8cc0bdd
3 changed files with 31 additions and 7 deletions

View File

@@ -226,13 +226,14 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
# NOTE: for access of private fields within generics from a different module
# we set the friend module:
c.friendModules.add(getModule(fn))
#let oldScope = c.currentScope
#c.currentScope = fn.scope
let oldScope = c.currentScope
while not isTopLevel(c): c.currentScope = c.currentScope.parent
result = copySym(fn, false)
incl(result.flags, sfFromGeneric)
result.owner = fn
result.ast = n
pushOwner(result)
openScope(c)
internalAssert n.sons[genericParamsPos].kind != nkEmpty
n.sons[namePos] = newSymNode(result)
@@ -264,7 +265,7 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
popInfoContext()
closeScope(c) # close scope for parameters
popOwner()
#c.currentScope = oldScope
c.currentScope = oldScope
discard c.friendModules.pop()
dec(c.instCounter)
if result.kind == skMethod: finishMethod(c, result)

View File

@@ -0,0 +1,27 @@
# bug #2752
import future, sequtils
proc myFilter[T](it: (iterator(): T), f: (proc(anything: T):bool)): (iterator(): T) =
iterator aNameWhichWillConflict(): T {.closure.}=
for x in it():
if f(x):
yield x
result = aNameWhichWillConflict
iterator testIt():int {.closure.}=
yield -1
yield 2
#let unusedVariable = myFilter(testIt, (x: int) => x > 0)
proc onlyPos(it: (iterator(): int)): (iterator(): int)=
iterator aNameWhichWillConflict(): int {.closure.}=
var filtered = onlyPos(myFilter(it, (x:int) => x > 0))
for x in filtered():
yield x
result = aNameWhichWillConflict
let x = onlyPos(testIt)

View File

@@ -61,10 +61,8 @@ Bugs
- VM: Pegs do not work at compile-time
- VM: ptr/ref T cannot work in general
- scopes are still broken for generic instantiation!
- blocks can "export" an identifier but the CCG generates {} for them ...
- ConcreteTypes in a 'case' means we don't check for duplicated case branches
- typedesc matches a generic type T!
version 0.9.x
@@ -79,8 +77,6 @@ version 0.9.x
- implement 'bits' pragmas
- we need a magic thisModule symbol
- optimize 'genericReset'; 'newException' leads to code bloat
- The 'do' notation might be trimmed so that its only purpose is to pass
multiple multi line constructs to a macro.
version 0.9.X