]> Cypherpunks repositories - gostls13.git/commit
go/ast: fix bug handling the result of yield in Preorder
authorRob Findley <rfindley@google.com>
Thu, 16 May 2024 14:08:12 +0000 (14:08 +0000)
committerRobert Findley <rfindley@google.com>
Thu, 16 May 2024 16:34:10 +0000 (16:34 +0000)
commit6a05055780e1beef8231ab1e05ffaf5754b1e5b6
treefd4dc51b876cc447e3ce6de9ee63a0d362a5e0f0
parentdb7bb2742ce01601842e277e7808d225ff8390cd
go/ast: fix bug handling the result of yield in Preorder

Once yield returns false, ast.Preorder must not call yield on any more
nodes. Even after the function passed to ast.Inspect returns false, it
may be invoked again with a non-nil node. Therefore, we must explicitly
truncate the inspection.

For #66339

Change-Id: I2b01e4e96a2d7aca785467c15ab59da13208c161
Reviewed-on: https://go-review.googlesource.com/c/go/+/585520
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/go/ast/walk.go
src/go/ast/walk_test.go [new file with mode: 0644]