#!stacks
"bug.Reportf" && "cache.(*action).exec.func3:+3" &&
  "unreachable.(*deadState).findDead:+17"

Issue created by stacks.

This stack indicates that the unreachable analyzer violates the SuggestedFix preconditions now documented and checked by the gopls analysis driver.

This stack Gf7EXQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.1 go1.23.5 windows/amd64 vscode (1)

Dups: EmaIvQ KznUPA JuVvTw 10HCWA mAqhog S-mQmQ 2q8x9A Vc6s2g yM5t_A Ne_rfg rN06Cw QGVc7g cp-4UQ fb8Dbg bgKp4Q H8EfOg tIGLig s00Qzg wX0s_A EFdz_A _AqRig 2l7h9g 6L5mmA g92Uyw 2e6Ziw B3yvxg SLq6lA eMJmBQ VMn62A nxVngw 4wnTaA H2vDzA S4gjMA -DlRtg Rm3VbQ Zumn2w H0xvEQ -ubuiA eFXWcg U_brvg TqSiJg ipVwYg Zumn1Q WCZHkQ nR04fA kIYX0g 0bITOw VdeswQ XFAqdQ PbQHuw 6voO2Q pZqskQ DA7D_A VH1-DA i9_tJQ n5N7dg tIGkrQ

Comment From: gabyhelp

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: prattmic

In v0.17.1, line 1143 was the third line of cache.(*action).exec.func3 (but is not a call to Reportf). Did stacks fetch the wrong version of the source?

https://cs.opensource.google/go/x/tools/+/refs/tags/gopls/v0.17.1:gopls/internal/cache/analysis.go;l=1143

Edit: oops, meant to post this on #71660.

Comment From: adonovan

Yes, I think a version skew is possible since the line numbers are not always off by one by some variable amount, which could correspond to recent changes in the code.

Comment From: adonovan

This stack indicates that the unreachable analyzer violates the SuggestedFix preconditions now documented and checked by the gopls analysis driver.

This call to pass.Report has a diagnostic with a single SuggestedFix of a single TextEdit (a deletion). The various possible errors returned by validateFix are:

  • "missing file info for pos (%v)" (File(start) == nil)
  • "pos (%v) > end (%v)" (end < start)
  • "malformed end position %v" (File(end) == nil, end))
  • "edit spans files %v and %v" (endFile != file)
  • "end is (%v) beyond end of file (%v)" (edit.End > file.Base() + file.Size()))

("overlapping edits" is not possible, nor is "analyzer %q suggests two fixes with same Message (%s)")

This means that at least one of stmt.Pos(), stmt.End() is invalid (zero, beyond EOF, or not mapped to a token.File). stmt is an element of ast.BlockStmt.List. The logic in the unreachable analyzer is unimpeachable, so I think either the parser recovery or the AST fixing logic must be to blame. Perhaps the input file is incomplete, something like func _() {return; var _ struct (EOF), and the parser's recovery has filled in values for the missing braces that are invalid or beyond EOF. This is especially likely if the Stmt.End() is computed by addition of a constant to the pos of some actual token.

Comment From: adonovan

Indeed, some variant of func _() {return; var _ struct did reproduce the bug.Report, but unfortunately the failure is silent to the user--the fix is discarded--so I had to check gopls bug to see it... but I lost the actual input as I tried many in a short span of time.

Nonetheless, it confirms that it's a truncated file AST repair issue, in other words another variant of https://github.com/golang/go/issues/66790#issuecomment-2050667924 (which is perhaps also the root cause of https://github.com/golang/go/issues/64547)

Comment From: adonovan

This stack KznUPA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.1 go1.23.6 darwin/arm64 vscode (1)

Comment From: adonovan

This stack JuVvTw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.1 go1.24rc3 darwin/arm64 sublimetext (1)

This stack 10HCWA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.1 go1.23.6 darwin/arm64 vscode,vscode-insiders (1)

Comment From: adonovan

This stack EmaIvQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.2 go1.23.6 linux/amd64 vscode (1)

Comment From: adonovan

This stack KznUPA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.2 go1.23.4 darwin/amd64 vscode (1)

This stack JuVvTw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.3 go1.24.0 darwin/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.2 go1.24.0 windows/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.1 go1.24.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.1 go1.24rc3 darwin/arm64 sublimetext (1)

Comment From: adonovan

This stack EmaIvQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.2 go1.23.6 linux/amd64 vscode (1)

This stack KznUPA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.2 go1.23.4 darwin/amd64 vscode (1)

This stack JuVvTw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.2 go1.24.0 windows/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.1 go1.24.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.1 go1.24rc3 darwin/arm64 sublimetext (1)
golang.org/x/tools/gopls@v0.18.0-pre.3 go1.24.0 darwin/amd64 vscode (1)

Comment From: adonovan

This stack 10HCWA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.3 go1.23.6 linux/amd64 other,vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.2 go1.23.6 darwin/arm64 vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.1 go1.23.5 windows/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.0-pre.1 go1.23.6 darwin/arm64 other,vscode (1)

Comment From: adonovan

Repro, found while investigating https://go.dev/cl/638395, which changes the parser behavior. Nonetheless it's pretty clear what class of errors this represents:

The missing label in the goto statement is currently not a parse error; but with CL 638395, it is an error, and it causes the parser to consume the }, which creates a cascade of errors. The FuncLit body is never closed, so the BlockStmt.End is computed to be (one) beyond the end of the file.

var _ = func() {
    goto
}

func _() int {
    switch {
    case 1:
        println()
    }
    println()
}

Comment From: gopherbot

Change https://go.dev/cl/651155 mentions this issue: go/analysis/passes/unreachable/testdata: relax test for CL 638395

Comment From: adonovan

This stack mAqhog was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0 go1.24.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.0 go1.24.0 darwin/arm64 vscode (1)

This stack S-mQmQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.2 go1.23.6 darwin/arm64 vscode (1)

Comment From: adonovan

This stack 2q8x9A was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0 go1.24.0 windows/amd64 vscode (1)

Comment From: gopherbot

Change https://go.dev/cl/652977 mentions this issue: [gopls-release-branch.0.18] go/analysis/passes/unreachable/testdata: relax test for CL 638395

Comment From: adonovan

This stack Vc6s2g was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0-pre.1 go1.23.6 darwin/arm64 vscode (1)

Comment From: adonovan

This stack yM5t_A was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 vscode (2)

This stack Ne_rfg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/arm64 neovim (1)

Comment From: adonovan

This stack rN06Cw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 vscode (1)

This stack QGVc7g was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode-insiders (1)

This stack cp-4UQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 other (2)

This stack fb8Dbg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode (1)

This stack bgKp4Q was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 other,vscode (1)

This stack H8EfOg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 other,vscode (1)

This stack tIGLig was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 other (1)

This stack s00Qzg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.0 go1.24.0 windows/amd64 vscode (1)

Comment From: adonovan

This stack wX0s_A was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 windows/amd64 vscode (1)

Comment From: adonovan

This stack EFdz_A was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode (1)

Comment From: adonovan

This stack _AqRig was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 vscode (1)

This stack 2l7h9g was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 linux/amd64 vscode (1)

Comment From: adonovan

This stack 6L5mmA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 windows/amd64 other (1)

This stack g92Uyw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 vscode (1)

This stack 2e6Ziw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 linux/amd64 vscode (1)

This stack B3yvxg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 other,vscode (1)

This stack SLq6lA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 windows/amd64 vscode (1)

This stack eMJmBQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 other,vscode (1)

Comment From: adonovan

This stack VMn62A was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 windows/amd64 vscode-insiders (1)

This stack nxVngw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 vscode (1)

This stack 4wnTaA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode (1)

This stack H2vDzA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode (1)

Comment From: adonovan

This stack S4gjMA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 other,vscode (1)

Comment From: adonovan

This stack -DlRtg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.5 linux/amd64 vscode (1)

Comment From: adonovan

This stack Rm3VbQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode (1)

This stack Zumn2w was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.1 linux/amd64 vscode-insiders (1)

This stack H0xvEQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 windows/amd64 vscode (1)

Comment From: adonovan

This stack -ubuiA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 windows/386 vscode (1)

This stack eFXWcg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 linux/amd64 vscode (1)

This stack U_brvg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 vscode (1)

Comment From: adonovan

This stack TqSiJg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 linux/amd64 vscode (1)

This stack ipVwYg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 windows/amd64 vscode (1)

This stack Zumn1Q was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode (1)

Comment From: adonovan

This stack WCZHkQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 windows/amd64 other,vscode (1)

This stack nR04fA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.4 linux/amd64 vscode (1)

This stack kIYX0g was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 vscode (1)

This stack 0bITOw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 vscode (1)

This stack VdeswQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 eglot,vscode (1)

Comment From: adonovan

This stack XFAqdQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 linux/amd64 vscode (1)

This stack PbQHuw was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 windows/amd64 vscode (1)

This stack 6voO2Q was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.1 windows/amd64 vscode (1)

Comment From: adonovan

This stack pZqskQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.4 linux/amd64 vscode (1)

This stack DA7D_A was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 windows/amd64 other,vscode (1)

This stack VH1-DA was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 darwin/arm64 other (1)

This stack i9_tJQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.1 darwin/arm64 vscode (1)

This stack n5N7dg was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 neovim (1)

This stack tIGkrQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.4 windows/amd64 vscode (1)

Comment From: gopherbot

Change https://go.dev/cl/660397 mentions this issue: gopls/internal/cache/parsego: fix truncated ASTs