]> Cypherpunks repositories - gostls13.git/commit
go/parser: Add TestBothLineAndLeadComment
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Mon, 15 Sep 2025 17:37:04 +0000 (19:37 +0200)
committerMateusz Poliwczak <mpoliwczak34@gmail.com>
Wed, 17 Sep 2025 13:43:57 +0000 (06:43 -0700)
commitbffe7ad9f11b874429d6c2561b0383e931502164
tree0c9c0f6bb334b3aeeab97900661af72f12e9dfbc
parent02a888e820f67d2b86892c41eeaadc8e32bb6f29
go/parser: Add TestBothLineAndLeadComment

I was wondering whether is is expected that both p.lineComment
and p.leadComment might be populated at the same time.

i.e. whether parser.go:275 can be changed from:

if p.lineFor(p.pos) != endline || p.tok == token.SEMICOLON || p.tok == token.EOF

to:

if (p.tok != token.COMMENT && p.lineFor(p.pos) != endline) || p.tok == token.SEMICOLON || p.tok == token.EOF

It turns out that we cannot do so. So while i am here, add a test
case for that, since nothing else failed with that change.

Change-Id: I6a6a6964f760237c068098db8a7b4b7aaf26c651
Reviewed-on: https://go-review.googlesource.com/c/go/+/703915
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/parser/parser_test.go