]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: document that (*ast.File).Comments is sorted by position
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Mon, 15 Sep 2025 19:14:25 +0000 (21:14 +0200)
committerAlan Donovan <adonovan@google.com>
Wed, 17 Sep 2025 13:33:19 +0000 (06:33 -0700)
This is the way that go/parser produces it and in every AST manipulation
that we do, we preserve such property. Also printer expects it is such
order.

Change-Id: I6a6a696424a679a2cf1f9bb7eb41bdd47523efa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/704255
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>
Auto-Submit: Alan Donovan <adonovan@google.com>

src/go/ast/ast.go

index 2a0d9e686021e87202148becc9ddcd81f06cb17e..9aca39e868f3fe2e4856bbc494310fd960635096 100644 (file)
@@ -1064,7 +1064,7 @@ type File struct {
        Scope              *Scope          // package scope (this file only). Deprecated: see Object
        Imports            []*ImportSpec   // imports in this file
        Unresolved         []*Ident        // unresolved identifiers in this file. Deprecated: see Object
-       Comments           []*CommentGroup // list of all comments in the source file
+       Comments           []*CommentGroup // comments in the file, in lexical order
        GoVersion          string          // minimum Go version required by //go:build or // +build directives
 }