sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.11k stars 1.29k forks source link

Go code intel fails to find results & gets merged in with search-based unexpectedly #22605

Open sqs opened 3 years ago

sqs commented 3 years ago

At https://sourcegraph.com/github.com/cortexproject/cortex@b4af68a8994a863875edf594a0a4c26b263772fa/-/blob/pkg/chunk/cache/background.go?L29:16#tab=references (which is in a repo that is auto-indexed), there are several Go code intel issues:

  1. The definition is from the Go stdlib, but go-to-definition goes to https://sourcegraph.com/github.com/cortexproject/cortex@b4af68a8994a863875edf594a0a4c26b263772fa/-/blob/pkg/util/sync.go?L12:6&subtree=true, which is from search-based and is another thing in the repo called WaitGroup.
  2. Find references shows no other semantic results for sync.WaitGroup even though there should be many.

I am not blocked on this specifically, so don't make this urgent because of me. I am curious to know why it is broken, though, and if this is a widespread issue.

image

github-actions[bot] commented 3 years ago

Heads up @macraig - the "team/code-intelligence" label was applied to this issue.

efritz commented 3 years ago

Looked into it: currently behaving as expected. That said, the expected behavior should be changed to match intuition. Addressing both points of your issue:

  1. The definition is from the go std lib, and the go-to-definition does indeed go to another repository's definition, which is unrelated. The UI currently gives you an indication of this (although maybe it's buried too deeply):
Screen Shot 2021-07-12 at 10 30 58 AM

You're getting Partial semantic results instead of Semantic results as either the hover text or the definition location is not precise. Usually you'll get Search-based (completely imprecise) or Precise (completely precise) results except for indexers that emit hover text for remote symbols (yes for Go, no for Java) and we don't have a full commit graph.

  1. We currently don't support linking to the go standard library. This is because monikers/symbols in the stdlib don't have any package information associated with it. This is fixable and there was a conscious decision to drop support in the past due to complexity; we never give it any engineering focus since. You can see that many other symbols in this repository (defined in a third party) does have multiple cross-repo results. This is an edge-case problem (one that I think is fairly important to fix at this time) and not a fundamental one. cc @macraig
olafurpg commented 3 years ago

Should this issue be closed? When I open the link now, I can only see the single "semantic" result from the sourcegraph/sourcegraph repository.

CleanShot 2021-07-15 at 17 40 40

Clicking on the "Mix precise and search-based results" button brings back the search-based results. It's a bit confusing that the label says "semantic" while the button says "precise". I believe we're settling on "precise" as the official term so we may want to consider updating the "semantic" label (cc/ @macraig )

efritz commented 3 years ago

@tjdevries Is this fixed by https://github.com/sourcegraph/lsif-go/issues/187?