Skip to content

Commit

Permalink
Fix loop closure generation for iterators with static parameters
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
can-lehmann committed Nov 13, 2023
1 parent 7648493 commit 0684a38
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions owlkettle/guidsl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,22 @@ macro customCapture(vars: varargs[typed], body: untyped): untyped =
var
params = @[newEmptyNode()]
args: seq[NimNode] = @[]

result = newStmtList()

for variable in vars:
let name = variable.unwrapName()
assert name.isName
params.add:
newIdentDefs(ident(name.strVal), variable.getTypeInst())

params.add(newIdentDefs(
ident(name.strVal),
newTree(nnkTypeOfExpr, variable)
))
args.add(variable)
result = newProc(

result.add(newProc(
params = params,
body = body
).newCall(args)
).newCall(args))

proc findVariables(node: NimNode): seq[NimNode] =
case node.kind:
Expand Down

0 comments on commit 0684a38

Please sign in to comment.