Search backend: fix symbol duplication
Created by: camdencheek
This fixes an issue where we would return duplicate symbols. This was happening because we were capturing a reference to a loop variable.
Maybe we should look at enabling https://github.com/kyoh86/exportloopref in our linters.
Fixes https://github.com/sourcegraph/sourcegraph/issues/31934
Test plan
Manually tested the minimal bug fix. I will followup with a PR that extracts that chunk of code and tests it.