From: Mateusz Poliwczak Date: Mon, 15 Sep 2025 19:14:25 +0000 (+0200) Subject: go/ast: document that (*ast.File).Comments is sorted by position X-Git-Tag: go1.26rc1~844 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=02a888e820;p=gostls13.git go/ast: document that (*ast.File).Comments is sorted by position 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Alan Donovan Auto-Submit: Alan Donovan --- diff --git a/src/go/ast/ast.go b/src/go/ast/ast.go index 2a0d9e6860..9aca39e868 100644 --- a/src/go/ast/ast.go +++ b/src/go/ast/ast.go @@ -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 }