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/internal/refactor/inline: panic in needsParens #71486

Open
adonovan opened this issue Jan 30, 2025 · 1 comment
Open

x/tools/internal/refactor/inline: panic in needsParens #71486

adonovan opened this issue Jan 30, 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
"gopanic" && "inline.needsParens:+4"

Issue created by stacks.

	res, err := st.inlineCall()
...
	// Replace the call (or some node that encloses it) by new syntax.
	assert(res.old != nil, "old is nil")
	assert(res.new != nil, "new is nil")
...
	if needsParens(caller.path, res.old, res.new) {
...
func needsParens(callPath []ast.Node, old, new ast.Node) bool {
	// Find enclosing old node and its parent.
	i := slices.Index(callPath, old)
	if i == -1 {
		panic("not found") <--- here
	}

This stack 0imOzQ was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.3 darwin/arm64 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 30, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 30, 2025
@adonovan
Copy link
Member Author

Another strange one: it appears to be a simple case of inlineCall returning a res.old node that is not an element of caller.path, but auditing all assignments to res.old, they all look like legitimate ancestors of the call node. Also, we have test coverage of at least all the strategies, so if any strategy were to return a non-ancestral node, it would be caught deterministically by the tests.

@findleyr findleyr self-assigned this Jan 30, 2025
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.18.0 Jan 30, 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