-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: analysis driver spuriously reports invalid suggested fixes due to AST repair #71659
Comments
In v0.17.1, line 1143 was the third line of Edit: oops, meant to post this on #71660. |
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. |
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:
("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 |
Indeed, some variant of Nonetheless, it confirms that it's a truncated file AST repair issue, in other words another variant of #66790 (comment) (which is perhaps also the root cause of #64547) |
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 var _ = func() {
goto
}
func _() int {
switch {
case 1:
println()
}
println()
} |
Change https://go.dev/cl/651155 mentions this issue: |
This test case is about to become a parse error. To allow us to submit the change to the parser, we must relax this test. Updates golang/go#71659 Updates golang/go#70957 Change-Id: Ic4fbfedb69d152d691dec41a94bb402149463f84 Reviewed-on: https://go-review.googlesource.com/c/tools/+/651155 Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
Change https://go.dev/cl/652977 mentions this issue: |
…relax test for CL 638395 This test case is about to become a parse error. To allow us to submit the change to the parser, we must relax this test. Updates golang/go#71659 Updates golang/go#70957 Change-Id: Ic4fbfedb69d152d691dec41a94bb402149463f84 Reviewed-on: https://go-review.googlesource.com/c/tools/+/651155 Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]> (cherry picked from commit d2fcd36) Reviewed-on: https://go-review.googlesource.com/c/tools/+/652977 Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Hongxiang Jiang <[email protected]>
Change https://go.dev/cl/660397 mentions this issue: |
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:gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.(*action).exec.func3:+3
golang.org/x/tools/go/analysis/passes/unreachable.(*deadState).findDead:+17
golang.org/x/tools/go/analysis/passes/unreachable.(*deadState).findDead:+49
golang.org/x/tools/go/analysis/passes/unreachable.run.func1:+19
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder:+20
golang.org/x/tools/go/analysis/passes/unreachable.run:+7
golang.org/x/tools/gopls/internal/cache.(*action).exec.func7:+31
golang.org/x/tools/gopls/internal/cache.(*action).exec:+282
golang.org/x/tools/gopls/internal/cache.execActions.func1.1:+2
sync.(*Once).doSlow:+5
sync.(*Once).Do:=67
golang.org/x/tools/gopls/internal/cache.execActions.func1:+2
runtime.goexit:+0
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
The text was updated successfully, but these errors were encountered: