internal/vettools: imageimportcheck reports an incorrect import position
Author: kumagiCreated Oct 1, 2026Updated Oct 1, 2026
Labelsos:linux
Ebitengine Version
main (ab841bf203427e7d8208598f58285b686bcfc45a)
Operating System
- Windows
- macOS
- Linux
- FreeBSD
- OpenBSD
- Android
- iOS
- Nintendo Switch
- PlayStation 5
- Xbox
- Web Browsers
Go Version (paste your go version output)
go version go1.27.1 linux/amd64
What steps will reproduce the problem?
Create a token.FileSet and parse first.go containing package p\nvar padding = 1\n. Then parse second.go containing package p\n\nimport _ "image/png"\n. Run runImageImportCheck on second.go with package path example.com/p and inspect the reported position.
What is the expected result?
The diagnostic points to second.go:3:8, the start of the import spec.
What happens instead?
The diagnostic points to second.go:3:22. An absolute token.Pos is incorrectly passed to token.File.Pos as a byte offset.
Anything else you feel useful to add?
Reproduced on main ab841bf203 with a focused analyzer regression test. Assigning the existing import spec position directly fixes the location.
Source: hajimehoshi/ebiten