mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 06:18:51 +00:00
@@ -17,25 +17,24 @@ proc semLocals*(c: PContext, n: PNode): PNode =
|
||||
var tupleType = newTypeS(tyTuple, c)
|
||||
result = newNodeIT(nkPar, n.info, tupleType)
|
||||
tupleType.n = newNodeI(nkRecList, n.info)
|
||||
let owner = getCurrOwner(c)
|
||||
# for now we skip openarrays ...
|
||||
for scope in walkScopes(c.currentScope):
|
||||
if scope == c.topLevelScope: break
|
||||
for it in items(scope.symbols):
|
||||
# XXX parameters' owners are wrong for generics; this caused some pain
|
||||
# for closures too; we should finally fix it.
|
||||
#if it.owner != c.p.owner: return result
|
||||
if it.kind in skLocalVars and
|
||||
it.typ.skipTypes({tyGenericInst, tyVar}).kind notin
|
||||
{tyVarargs, tyOpenArray, tyTypeDesc, tyStatic, tyUntyped, tyTyped, tyEmpty}:
|
||||
|
||||
var field = newSym(skField, it.name, getCurrOwner(c), n.info)
|
||||
field.typ = it.typ.skipTypes({tyVar})
|
||||
field.position = counter
|
||||
inc(counter)
|
||||
if it.owner == owner:
|
||||
var field = newSym(skField, it.name, owner, n.info)
|
||||
field.typ = it.typ.skipTypes({tyVar})
|
||||
field.position = counter
|
||||
inc(counter)
|
||||
|
||||
addSon(tupleType.n, newSymNode(field))
|
||||
addSonSkipIntLit(tupleType, field.typ)
|
||||
addSon(tupleType.n, newSymNode(field))
|
||||
addSonSkipIntLit(tupleType, field.typ)
|
||||
|
||||
var a = newSymNode(it, result.info)
|
||||
if it.typ.skipTypes({tyGenericInst}).kind == tyVar: a = newDeref(a)
|
||||
result.add(a)
|
||||
var a = newSymNode(it, result.info)
|
||||
if it.typ.skipTypes({tyGenericInst}).kind == tyVar: a = newDeref(a)
|
||||
result.add(a)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
discard """
|
||||
output: '''(x: "string here", a: 1)'''
|
||||
output: '''(x: "string here", a: 1)
|
||||
b is 5
|
||||
x is 12'''
|
||||
"""
|
||||
|
||||
proc simple[T](a: T) =
|
||||
@@ -28,3 +30,35 @@ proc test(baz: int, qux: var int): int =
|
||||
|
||||
var x1 = 456
|
||||
discard test(123, x1)
|
||||
|
||||
# bug #11958
|
||||
proc foo() =
|
||||
var a = 5
|
||||
proc bar() {.nimcall.} =
|
||||
var b = 5
|
||||
for k, v in fieldpairs(locals()):
|
||||
echo k, " is ", v
|
||||
|
||||
bar()
|
||||
foo()
|
||||
|
||||
|
||||
proc foo2() =
|
||||
var a = 5
|
||||
proc bar2() {.nimcall.} =
|
||||
for k, v in fieldpairs(locals()):
|
||||
echo k, " is ", v
|
||||
|
||||
bar2()
|
||||
foo2()
|
||||
|
||||
|
||||
proc foo3[T](y: T) =
|
||||
var a = 5
|
||||
proc bar2[T](x: T) {.nimcall.} =
|
||||
for k, v in fieldpairs(locals()):
|
||||
echo k, " is ", v
|
||||
|
||||
bar2(y)
|
||||
|
||||
foo3(12)
|
||||
|
||||
Reference in New Issue
Block a user