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
This commit is contained in:
parent
6b5e2adfd0
commit
e07ab06f0a
2 changed files with 20 additions and 1 deletions
|
|
@ -9,3 +9,22 @@ proc simple[T](a: T) =
|
|||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue