[go] go/types: fix inNode debug assertion for "for range x {}"

0 views
Skip to first unread message

Robert Findley (Gerrit)

unread,
Apr 14, 2026, 10:49:51 AM (yesterday) Apr 14
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, David Chase, Robert Griesemer, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com

Robert Findley submitted the change

Change information

Commit message:
go/types: fix inNode debug assertion for "for range x {}"

For a RangeStmt with no range variables, s.TokPos is invalid (NoPos).
The inNode debug assertion (start <= pos && pos < end) fails on the
zero pos. The position is unused in that case (noNewVarPos is only
read when isDef is true), but inNode still asserts.

Use s.For as a fallback so the assertion holds. types2 is unaffected
because syntax.ForStmt does not have this shape.

Found while running go/types tests with debug=true.
Change-Id: I82ebffca98bc9f41cda4364d31d0845bac97b5ae
Reviewed-by: Robert Griesemer <g...@google.com>
Reviewed-by: David Chase <drc...@google.com>
Files:
  • M src/go/types/stmt.go
Change size: XS
Delta: 1 file changed, 7 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I82ebffca98bc9f41cda4364d31d0845bac97b5ae
Gerrit-Change-Number: 766181
Gerrit-PatchSet: 3
Gerrit-Owner: Robert Findley <rfin...@golang.org>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@golang.org>
Gerrit-Reviewer: Robert Griesemer <g...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages