x/tools/go/analysis/analysistest: buggy // want
behavior with block comments
#65003
Labels
FrozenDueToAge
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
Go version
go version go1.21.1 linux/amd64
Output of
go env
in your module/workspace:golang.org/x/tools version
What did you do?
I wrote an analysistest testdata containing a file like this:
with a very simple
analysistest.Run
like this:What did you see happen?
That test fails with an error like this:
while also missing the lack of report on the other
// want "comment"
further down.Which is very simply reproduced here: Groxx/analysisbug@4178723
I'm not sure how to build that into go.dev/play, but I'd be willing to try if someone can point me to a general strategy / an example analysistest with a testdata folder (or writing one during the test).
Other block-comment structures seem to produce a variety of behaviors like this:
unexpected diagnostic: anything
where// want "anything"
exists// want "comment"
/ not noticing the missing reportdiagnostic "anything" does not match pattern "anything"
where// want "anything"
existsin 'want' comment: got Ident after [the next word in the comment], want ':'
either on the comment's line or sometimes a different nearby lineThe single-line
// comment
variants of all of these work as expected, as do all single-line/* comment // want "something" */
comments. It seems to be just multi-line blocks causing issues.2 and 4 are reproduced in my sample repository at this (initial) commit: Groxx/analysisbug@4178723
The other two I see in a larger project where I'm less confident about what's my flaw and what's a
// want
issue, and I have not yet managed to reproduce them in a small test.I kinda suspect they'll be fixed in the process of finding and fixing 2 and 4 though so I haven't sunk much energy into that yet. I can push the (extremely messy) state of that repository if it seems actually useful though.
What did you expect to see?
// want
comments should work the same in both multi-line/* comments */
and// comment
lines.The text was updated successfully, but these errors were encountered: