Fix capture for object types (#13315)
* Fix capture for object|tuple|... types * Add test case
This commit is contained in:
parent
45a5c64c9a
commit
d43e5bef39
2 changed files with 17 additions and 3 deletions
|
|
@ -184,7 +184,7 @@ macro capture*(locals: openArray[typed], body: untyped): untyped {.since: (1, 1)
|
|||
## echo r[0] & ", or " & r[1] # output: to be, or not to be
|
||||
var params = @[newIdentNode("auto")]
|
||||
for arg in locals:
|
||||
params.add(newIdentDefs(ident(arg.strVal), freshIdentNodes getTypeImpl arg))
|
||||
params.add(newIdentDefs(ident(arg.strVal), freshIdentNodes getTypeInst arg))
|
||||
result = newNimNode(nnkCall)
|
||||
result.add(newProc(newEmptyNode(), params, body, nnkProcDef))
|
||||
for arg in locals: result.add(arg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue