Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: "expected exported symbol" assert in getOneTransitiveRefLocked #71356

Open
adonovan opened this issue Jan 20, 2025 · 1 comment
Assignees
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

#!stacks
"cache.assert" && "evaluatePackageHandle.func1:+2"

Issue created by stacks.

// getOneTransitiveRefLocked computes the full set packages transitively
// reachable through the given sym reference.
//
// It may return nil if the reference is invalid (i.e. the referenced name does
// not exist).
func (b *packageHandleBuilder) getOneTransitiveRefLocked(sym typerefs.Symbol) *typerefs.PackageSet {
	assert(token.IsExported(sym.Name), "expected exported symbol")  <--- here

	trefs := b.transitiveRefs[sym.Package]
	if trefs == nil {
		trefs = &partialRefs{
			refs:     make(map[string]*typerefs.PackageSet),
			complete: false,
		}
		b.transitiveRefs[sym.Package] = trefs
	}

This stack N2fS6w was reported by telemetry:

golang.org/x/tools/gopls@v0.17.0 go1.23.4 linux/amd64 vscode (1)
@adonovan adonovan added gopls Issues related to the Go language server, gopls. gopls/telemetry-wins NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository. labels Jan 20, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 20, 2025
@adonovan
Copy link
Member Author

What we know:

  • sym.Name is non-exported.
  • sym comes from a value in the node.ph.refs map.
  • the refs map is set by evaluatePackageHandle to the result of Snapshot.typerefs()
  • its values from the Refs field of the result of typerefs.Decode.
  • assuming the encode/decode pair is lossless, this value must have come from typesrefs.state.class, which is inserted by state.getClassIndex.
  • this value comes from typestate.declNode.extRefs.
  • extRefs is inserted in three places, two of which are unions (inductive case); the third (base case) is the importEdge lambda in typerefs.visitFile, which is dominated a token.IsExported check.

So, this can't happen (modulo: bugs in encode/decode pair, compiler, runtime, hardware). What am I missing?

@adonovan adonovan modified the milestones: Unreleased, gopls/v0.18.0 Jan 21, 2025
@findleyr findleyr self-assigned this Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants