MiSawa / xq

Pure rust implementation of jq
MIT License
333 stars 18 forks source link

Fix for recursive call of a closure #6

Closed MiSawa closed 3 years ago

MiSawa commented 3 years ago

I think we can call a closure recursively through a function. So we'll probably need a scope for closures that require slots.

MiSawa commented 3 years ago

Actually this might not be true...

MiSawa commented 3 years ago
def f: def g(x): ., x; g((. + 1) as $v | $v | if . > 2 then empty else f, $v end); f

calls a closure recursively (kinda), but the frame of f are different for each recursion so it works.

I'm skeptical about the existence of a query that calls a closure recursively within the same frame.

MiSawa commented 3 years ago

Ah actually I did emit NewScope on closures as well. So it should be fine even if there exists such query.