[tools] go/ast/astutil: update BasicLit.ValueEnd if present

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Dec 3, 2025, 1:00:15 PM (14 hours ago) Dec 3
to Alan Donovan, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Robert Findley, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: go/ast/astutil/imports.go
Insertions: 2, Deletions: 2.

@@ -473,7 +473,7 @@
}

// setBasicLitValuePos updates lit.Pos,
-// ensuring that lit.End is displaced by the same amount.
+// ensuring that lit.End (if set) is displaced by the same amount.
// (See https://go.dev/issue/76395.)
func updateBasicLitPos(lit *ast.BasicLit, pos token.Pos) {
len := lit.End() - lit.Pos()
@@ -481,7 +481,7 @@
// TODO(adonovan): after go1.26, simplify to:
// lit.ValueEnd = pos + len
v := reflect.ValueOf(lit).Elem().FieldByName("ValueEnd")
- if v.IsValid() {
+ if v.IsValid() && v.Int() != 0 {
v.SetInt(int64(pos + len))
}
}
```

Change information

Commit message:
go/ast/astutil: update BasicLit.ValueEnd if present

This is a putative fix; I haven't been able to reproduce
the problem locally yet.

Fixes golang/go#76395
For golang/go#76031
Change-Id: I2fe3d96e60629fd360563021e42acc5b248d7ff2
Auto-Submit: Alan Donovan <adon...@google.com>
Reviewed-by: Robert Findley <rfin...@google.com>
Files:
  • M go/ast/astutil/imports.go
  • M internal/imports/sortimports.go
Change size: S
Delta: 2 files changed, 36 insertions(+), 6 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Robert Findley
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I2fe3d96e60629fd360563021e42acc5b248d7ff2
Gerrit-Change-Number: 722840
Gerrit-PatchSet: 3
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages