If I understand the implementation of `capture` correctly, this is what your code expands to: import std/tables, sugar proc getProc(): (proc()) = var tab: Table[string, string] (proc(tab: auto): proc() = return (proc() = echo "Hello World" ) )(tab) Run
So the error is not referring to the proc you’re returning, but to the proc generated by `capture`. If you replace the `auto` with `Table[string, string]` in the expanded code, it seems to work.