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

It was creating an `ObjectRef[<notype>]` because of a small
bug in `capturedVariableType`.

Review by @xeno-by