SI-7558 Fix capture of free local vars in toolbox compiler

It was creating an `ObjectRef[<notype>]` because of a small
bug in `capturedVariableType`.
Merge pull request #2629 from retronym/ticket/7558

SI-7558 Fix capture of free local vars in toolbox compiler