x/tools/go/analysis/internal/checker: if offsetedit
's start is 0, it can't be apply
#54774
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm developing an linter to remove duplicate words from comments.(Yes, I know this scenario would be fine in many cases using the text tool, I just wanted to learn go ast by the way)
When my test file is as follows:
After run
dupword -fix ./...
this file become :package a
My
analysis.Diagnostic.SuggestedFixes.TextEdits
ishttps://github.com/golang/tools/blob/248c34b88a4148128f89e41923498bd86f805b7d/go/analysis/internal/checker/checker.go#L377
change to
offsetedit
, theoffsetedit.start
is 0. And it is ignored in https://github.com/golang/tools/blob/master/go/analysis/internal/checker/checker.go#L408What did you expect to see?
even if
TextEdits.Pos
is 0, it can be applied.What did you see instead?
Just be deleted.
The text was updated successfully, but these errors were encountered: