]> Cypherpunks repositories - gostls13.git/commit
cmd/doc: make -src mode deterministic
authorIvan Trubach <mr.trubach@icloud.com>
Mon, 2 Sep 2019 13:57:09 +0000 (13:57 +0000)
committerAgniva De Sarker <agniva.quicksilver@gmail.com>
Mon, 2 Sep 2019 15:31:19 +0000 (15:31 +0000)
commit060669a68938a450235ca3c721e4095c9f320503
treec5fb20035d3e13e61cda0eb3bfc6246515549aac
parent2f04903fec99e8b8291f1bfa91590bddb1b93c68
cmd/doc: make -src mode deterministic

These changes make cmd/doc -src deterministic, or, more precisely,
go/ast.MergePackageFiles, which is used by cmd/doc. So far the order of
comments depended on the package file map iteration order.

cmd/doc with -src flag has been inserting and omitting random comments
ever since the addition of -src flag. After investigating the code path
with the debugger, I’ve noticed that ast.File.Comments slice order changes
between invocations of the command. The bug was introduced in 3e24f2d,
which ironically claimed to “fix formatting of -src output”. The commit
implemented the collection of comments by iterating over the map and
c7cdce1 “godoc: make ?m=src mode deterministic” did’t actually make
go/ast.MergePackageFiles deterministic.

I’ve found this issue after running “go doc -src sync.WaitGroup.Wait”.
There are likely other packages and functions affected, but the bug
should be somewhat reproducible across all Go versions.

Change-Id: Iae223e99550c0a3b54005c5cde36f909e655b66b
GitHub-Last-Rev: c49532f79fcd7529d7ad1a369c467abc59d4df0a
GitHub-Pull-Request: golang/go#33553
Reviewed-on: https://go-review.googlesource.com/c/go/+/189477
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/ast/filter.go