Files
Nim/tests/misc/tlocals.nim
LemonBoy e07ab06f0a Fix locals() interaction with generic types
Follow the same logic as semTupleFieldsConstr and only skip skVar since
we're gonna add a nkDefer anyway.

Fixes #8985
2018-09-21 22:35:54 +02:00

31 lines
536 B
Nim

discard """
output: '''(x: "string here", a: 1)'''
"""
proc simple[T](a: T) =
var
x = "string here"
echo locals()
simple(1)
type Foo2[T]=object
a2: T
proc numFields*(T: typedesc[tuple|object]): int=
var t:T
for _ in t.fields: inc result
proc test(baz: int, qux: var int): int =
var foo: Foo2[int]
let bar = "abc"
let c1 = locals()
doAssert numFields(c1.foo.type) == 1
doAssert c1.bar == "abc"
doAssert c1.baz == 123
doAssert c1.result == 0
doAssert c1.qux == 456
var x1 = 456
discard test(123, x1)